Improve handling of timespans

This commit is contained in:
Joshua Ramon Enslin 2021-05-13 23:00:23 +02:00
parent 2a8ba31410
commit 6a91e31f41
Signed by: jrenslin
GPG Key ID: 46016F84501B70AE

View File

@ -1030,8 +1030,9 @@ final class NodaTimeSplitter {
$middle_substraction = round($days_diff / 2);
$middle_day = date('Y-m-d',
strtotime('+' . $middle_substraction . ' days', strtotime($startDate->format('Y-m-d'))));
if (!($startDateTimestamp = strtotime($startDate->format('Y-m-d')))) return [];
if (!($middleDayTimestamp = strtotime('+' . $middle_substraction . ' days', $startDateTimestamp))) return [];
$middle_day = date('Y-m-d', $middleDayTimestamp);
$start_name = self::timePartsToTimeName($start);
$end_name = self::timePartsToTimeName($end);