Skip to content

Add start & end datetime normalization #7

@juniwalk

Description

@juniwalk

Method from Events trait in Servis7 application.

private function normalizeDateTime(?DateTimeInterface $date): ?DateTime
{
	if (is_null($date)) {
		return null;
	}

	$date = DateTime::createFromInterface($date);
	$minute = (int) $date->format('i');
	$hour = (int) $date->format('H');

	if ($minute >= 45) {
		return $date->setTime($hour + 1, 00);
	}

	if ($minute >= 15) {
		return $date->setTime($hour, 30);
	}

	return $date->setTime($hour, 00);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions