1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
closestworkdatetrait.php
См. документацию.
1<?php
2
3declare(strict_types=1);
4
6
10
11trait ClosestWorkDateTrait
12{
13 protected function getClosestWorkDate(DateTime $start): DateTime
14 {
15 $currentDate = clone $start;
16
17 for ($counter = 0; $counter < 365; $counter++)
18 {
19 if ($this->schedule->isWeekend($currentDate))
20 {
21 $currentDate->add('1 day');
22
23 continue;
24 }
25
26 $workDayStart = $this->schedule->getShiftStart($currentDate);
27 $workDayEnd = $this->schedule->getShiftEnd($currentDate);
28
29 if ($currentDate->getTimestamp() > $workDayEnd->getTimestamp())
30 {
31 $currentDate->setTime(0, 0);
32 $currentDate->add('1 day');
33
34 continue;
35 }
36
37 if ($currentDate->getTimeStamp() > $workDayStart->getTimeStamp())
38 {
39 return $currentDate;
40 }
41
42 return $workDayStart;
43 }
44
45 $exception = new LoopException('Probably infinite loop with date ' . $start->toString());
46 Application::getInstance()->getExceptionHandler()->writeToLog($exception);
47
48 return $currentDate;
49 }
50}
$start
Определения get_search.php:9
$counter
Определения options.php:5