Closed gerardnll closed 2 years ago
Hello,
When creating a Period like this:
Period::make('10:00', '11:00', Precision::MINUTE(), Boundaries::EXCLUDE_END(), 'H:i');
Hours, minutes and seconds are cleared in the PeriodFactory.php lines 107-109:
if (! str_contains($format, ' ')) { $dateTime = $dateTime->setTime(0, 0, 0); }
So this is wrong:
$period1 = Period::make('10:00', '11:00', Precision::MINUTE(), Boundaries::EXCLUDE_END(), 'H:i'); $period2 = Period::make('10:00', '11:00', Precision::MINUTE(), Boundaries::EXCLUDE_END(), 'H:i'); $period1->overlapsWith($period2); // false
Is there a reason why times are being cleared? Could we not do it depending on the precision instead of expecting a date format + time format?
Temporal (or not) fix:
Period::make(Date::now()->setTimeFromTimeString('10:00'), Date::now()->setTimeFromTimeString('11:00'), Precision::MINUTE(), Boundaries::EXCLUDE_END());
Feel free to send a PR for this. Make sure to include tests.
Hello,
When creating a Period like this:
Period::make('10:00', '11:00', Precision::MINUTE(), Boundaries::EXCLUDE_END(), 'H:i');
Hours, minutes and seconds are cleared in the PeriodFactory.php lines 107-109:
So this is wrong:
Is there a reason why times are being cleared? Could we not do it depending on the precision instead of expecting a date format + time format?
Temporal (or not) fix:
Period::make(Date::now()->setTimeFromTimeString('10:00'), Date::now()->setTimeFromTimeString('11:00'), Precision::MINUTE(), Boundaries::EXCLUDE_END());