3declare(strict_types=1);
11trait ClosestWorkDateTrait
15 $currentDate = clone
$start;
19 if ($this->schedule->isWeekend($currentDate))
21 $currentDate->add(
'1 day');
26 $workDayStart = $this->schedule->getShiftStart($currentDate);
27 $workDayEnd = $this->schedule->getShiftEnd($currentDate);
29 if ($currentDate->getTimestamp() > $workDayEnd->getTimestamp())
31 $currentDate->setTime(0, 0);
32 $currentDate->add(
'1 day');
37 if ($currentDate->getTimeStamp() > $workDayStart->getTimeStamp())
45 $exception =
new LoopException(
'Probably infinite loop with date ' .
$start->toString());
46 Application::getInstance()->getExceptionHandler()->writeToLog($exception);