date-time icon indicating copy to clipboard operation
date-time copied to clipboard

Add LocalDateTimeRange

Open antonkomarev opened this issue 4 years ago • 1 comments

It will be useful to have LocalDateTimeRange to encapsulate start and end datetime. Quite similar to the LocalDateRange.

Otherwise we need to do something like this if we want to pass range as one parameter.

private function getRegistrationsBetweenDates(
    LocalDateRange $dateRange
): array {
    $registeredAtFrom = $dateRange->getStart()->atTime(LocalTime::min());
    $registeredAtTo = $dateRange->getEnd()->atTime(LocalTime::max());

    // ...
}

But this way we can only use 00:00:00 and 23:59:59 time.

Prososal:

private function getRegistrationsBetweenDateTimes(
    LocalDateTimeRange $dateTimeRange
): array {
    $registeredAtFrom = $dateTimeRange->getStart();
    $registeredAtTo = $dateTimeRange->getEnd();

    // ...
}

antonkomarev avatar May 26 '21 16:05 antonkomarev

A comment worth referencing here : https://github.com/brick/date-time/issues/45#issuecomment-1173093592

gnutix avatar Jul 03 '22 13:07 gnutix