3declare(strict_types=1);
39 'WEEKEND' => [
'SA',
'SU'],
58 $this->parseWeekend();
59 $this->parseHolidays();
60 $this->parseWorkHours();
61 $this->parseWorkTime();
68 return (clone $date)->setTime($this->startHour, $this->startMinute);
75 return (clone $date)->setTime($this->endHour, $this->endMinute);
80 $secondsInStartOfWorkDay = $this->startHour * static::SECONDS_IN_HOUR + $this->startMinute * self::SECONDS_IN_MINUTE;
81 $secondsInEndOfWorkDay = $this->endHour * static::SECONDS_IN_HOUR + $this->endMinute * self::SECONDS_IN_MINUTE;
83 return $secondsInEndOfWorkDay - $secondsInStartOfWorkDay;
90 $now = (int)$date->
format(
'H') * self::MINUTES_IN_HOUR + (int)$date->
format(
'i');
92 return $now >=
$start && $now <= $end;
97 $weekday = (int)$date->
format(
'w');
99 if (isset($this->weekend[$weekday]))
104 $month = (int)$date->
format(
'n');
105 $day = (int)$date->
format(
'j');
107 return isset($this->holidays[$month .
'_' . $day]);
116 $this->startHour = (int)
$hours[
'START'][
'H'];
117 $this->startMinute = (int)
$hours[
'START'][
'M'];
118 $this->endHour = (int)
$hours[
'END'][
'H'];
119 $this->endMinute = (int)
$hours[
'END'][
'M'];
125 $this->parseWeekend();
126 $this->parseHolidays();
127 $this->parseWorkTime();
152 [$day, $month] = explode(
'.', $day);
156 $settings[
'HOLIDAYS'][] = [
'M' => (int)$month,
'D' => (
int)$day];
164 if (isset($timeStart[0]))
166 $settings[
'HOURS'][
'START'][
'H'] = (int)$timeStart[0];
168 if (isset($timeStart[1]))
170 $settings[
'HOURS'][
'START'][
'M'] = (int)$timeStart[1];
175 if (isset($timeEnd[0]))
177 $settings[
'HOURS'][
'END'][
'H'] = (int)$timeEnd[0];
179 if (isset($timeEnd[1]))
181 $settings[
'HOURS'][
'END'][
'M'] = (int)$timeEnd[1];
192 private function parseWeekend(): void
194 if(!empty($this->settings[
'WEEKEND']) && is_array($this->settings[
'WEEKEND']))
196 foreach ($this->settings[
'WEEKEND'] as $day)
198 $this->weekend[static::DAY_MAP[$day]] =
true;
202 if(
count($this->weekend) === static::WEEK_DAYS_COUNT)
204 $this->weekend = [static::DAY_MAP[
'SA'] =>
true, static::DAY_MAP[
'SU'] =>
true];
208 private function parseHolidays(): void
210 $holidays = $this->settings[
'HOLIDAYS'] ?? [];
214 $this->holidays[(int)$day[
'M'] .
'_' . (
int)$day[
'D']] =
true;
218 private function parseWorkHours(): void
220 $startHour = $this->settings[
'HOURS'][
'START'][
'H'] ??
null;
227 $startMinute = $this->settings[
'HOURS'][
'START'][
'M'] ??
null;
234 $endHour = $this->settings[
'HOURS'][
'END'][
'H'] ??
null;
241 $endMinute = $this->settings[
'HOURS'][
'END'][
'M'] ??
null;
249 private function parseWorkTime(): void
isWeekend(DateTime $date)
__construct(?array $settings=null)
getWorkDayDuration(?DateTime $date=null)
getShiftStart(?DateTime $date=null)
getShiftEnd(?DateTime $date=null)
setSettings(array $settings)
isWorkTime(DateTime $date)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"