Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
DateLib.php
1<?php
2
4
9
10class DateLib extends BaseLib
11{
12 private static $weekHolidays;
13 private static $yearHolidays;
14 private static $startWorkDay;
15 private static $endWorkDay;
16 private static $yearWorkdays;
17
18 function getFunctions(): array
19 {
20 return [
21 'date' => [
22 'args' => true,
23 'func' => 'callDate',
24 'description' => Loc::getMessage('BIZPROC_CALC_FUNCTION_DATE_DESCRIPTION'),
25 ],
26 'dateadd' => [
27 'args' => true,
28 'func' => 'callDateAdd',
29 'description' => Loc::getMessage('BIZPROC_CALC_FUNCTION_DATEADD_DESCRIPTION'),
30 ],
31 'datediff' => [
32 'args' => true,
33 'func' => 'callDateDiff',
34 'description' => Loc::getMessage('BIZPROC_CALC_FUNCTION_DATEDIFF_DESCRIPTION'),
35 ],
36 'addworkdays' => [
37 'args' => true,
38 'func' => 'callAddWorkDays',
39 'description' => Loc::getMessage('BIZPROC_CALC_FUNCTION_ADDWORKDAYS_DESCRIPTION'),
40 ],
41 'workdateadd' => [
42 'args' => true,
43 'func' => 'callWorkDateAdd',
44 'description' => Loc::getMessage('BIZPROC_CALC_FUNCTION_WORKDATEADD_DESCRIPTION'),
45 ],
46 'isworkday' => [
47 'args' => true,
48 'func' => 'callIsWorkDay',
49 'description' => Loc::getMessage('BIZPROC_CALC_FUNCTION_ISWORKDAY_DESCRIPTION'),
50 ],
51 'isworktime' => [
52 'args' => true,
53 'func' => 'callIsWorkTime',
54 'description' => Loc::getMessage('BIZPROC_CALC_FUNCTION_ISWORKTIME_DESCRIPTION'),
55 ],
56 'touserdate' => [
57 'args' => true,
58 'func' => 'callToUserDate',
59 'description' => Loc::getMessage('BIZPROC_CALC_FUNCTION_TOUSERDATE_DESCRIPTION'),
60 ],
61 'getuserdateoffset' => [
62 'args' => true,
63 'func' => 'callGetUserDateOffset',
64 'description' => Loc::getMessage('BIZPROC_CALC_FUNCTION_GETUSERDATEOFFSET_DESCRIPTION'),
65 ],
66 'strtotime' => [
67 'args' => true,
68 'func' => 'callStrtotime',
69 'description' => Loc::getMessage('BIZPROC_CALC_FUNCTION_STRTOTIME_DESCRIPTION'),
70 ],
71 'locdate' => [
72 'args' => true,
73 'func' => 'callLocDate',
74 'description' => Loc::getMessage('BIZPROC_CALC_FUNCTION_LOCDATE_DESCRIPTION'),
75 ],
76 'settime' => [
77 'args' => true,
78 'func' => 'callSetTime',
79 'description' => Loc::getMessage('BIZPROC_CALC_FUNCTION_SETTIME_DESCRIPTION'),
80 ],
81 ];
82 }
83
84 public function callDateAdd(Arguments $args)
85 {
86 $date = $args->getFirstSingle();
87 $offset = $this->getDateTimeOffset($date);
88 $date = $this->makeTimestamp($date);
89 $interval = $args->getSecondSingle();
90
91 if ($date === false || ($interval && !is_scalar($interval)))
92 {
93 return null;
94 }
95
96 if (empty($interval))
97 {
98 return $date; // new Bizproc\BaseType\Value\DateTime($date, $offset);
99 }
100
101 // 1Y2M3D4H5I6S, -4 days 5 hours, 1month, 5h
102
103 $interval = trim($interval);
104 $bMinus = false;
105 if (mb_substr($interval, 0, 1) === "-")
106 {
107 $interval = mb_substr($interval, 1);
108 $bMinus = true;
109 }
110
111 static $arMap = [
112 "y" => "YYYY",
113 "year" => "YYYY",
114 "years" => "YYYY",
115 "m" => "MM",
116 "month" => "MM",
117 "months" => "MM",
118 "d" => "DD",
119 "day" => "DD",
120 "days" => "DD",
121 "h" => "HH",
122 "hour" => "HH",
123 "hours" => "HH",
124 "i" => "MI",
125 "min" => "MI",
126 "minute" => "MI",
127 "minutes" => "MI",
128 "s" => "SS",
129 "sec" => "SS",
130 "second" => "SS",
131 "seconds" => "SS",
132 ];
133
134 $arInterval = [];
135 while (preg_match('/\s*([\d]+)\s*([a-z]+)\s*/i', $interval, $match))
136 {
137 $match2 = mb_strtolower($match[2]);
138 if (array_key_exists($match2, $arMap))
139 {
140 $arInterval[$arMap[$match2]] = ($bMinus ? -intval($match[1]) : intval($match[1]));
141 }
142
143 $p = mb_strpos($interval, $match[0]);
144 $interval = mb_substr($interval, $p + mb_strlen($match[0]));
145 }
146
147 $date += $offset; // to server
148
149 $newDate = AddToTimeStamp($arInterval, $date);
150
151 $newDate -= $offset; // to user timezone
152
153 return new Bizproc\BaseType\Value\DateTime($newDate, $offset);
154 }
155
156 public function callWorkDateAdd(Arguments $args)
157 {
158 $date = $args->getFirstSingle();
159 $offset = $this->getDateTimeOffset($date);
160 $paramInterval = $args->getSecondSingle();
161 $user = $args->getThird();
162
163 if ($user)
164 {
165 $userArgs = clone $args;
166 $userArgs->setArgs([$user, $date]);
167
168 $date = $this->callToUserDate($userArgs);
169 $offset = $this->getDateTimeOffset($date);
170 }
171
172 $date = $this->makeTimestamp($date, true);
173
174 if ($date === false || ($paramInterval && !is_scalar($paramInterval)))
175 {
176 return null;
177 }
178
179 if (empty($paramInterval) || !Main\Loader::includeModule('calendar'))
180 {
181 return $date;
182 }
183
184 $paramInterval = trim($paramInterval);
185 $multiplier = 1;
186 if (mb_substr($paramInterval, 0, 1) === "-")
187 {
188 $paramInterval = mb_substr($paramInterval, 1);
189 $multiplier = -1;
190 }
191
192 $workDayInterval = $this->getWorkDayInterval();
193 $intervalMap = [
194 "d" => $workDayInterval,
195 "day" => $workDayInterval,
196 "days" => $workDayInterval,
197 "h" => 3600,
198 "hour" => 3600,
199 "hours" => 3600,
200 "i" => 60,
201 "min" => 60,
202 "minute" => 60,
203 "minutes" => 60,
204 ];
205
206 $interval = 0;
207 while (preg_match('/\s*([\d]+)\s*([a-z]+)\s*/i', $paramInterval, $match))
208 {
209 $match2 = mb_strtolower($match[2]);
210 if (array_key_exists($match2, $intervalMap))
211 {
212 $interval += intval($match[1]) * $intervalMap[$match2];
213 }
214
215 $p = mb_strpos($paramInterval, $match[0]);
216 $paramInterval = mb_substr($paramInterval, $p + mb_strlen($match[0]));
217 }
218
219 if (date('H:i:s', $date) === '00:00:00')
220 {
221 //add start work day seconds
222 $date += $this->getCalendarWorkTime()[0];
223 }
224
225 $date = $this->getNearestWorkTime($date, $multiplier);
226 if ($interval)
227 {
228 $days = (int)floor($interval / $workDayInterval);
229 $hours = $interval % $workDayInterval;
230
231 $remainTimestamp = $this->getWorkDayRemainTimestamp($date, $multiplier);
232
233 if ($days)
234 {
235 $date = $this->addWorkDay($date, $days * $multiplier);
236 }
237
238 if ($hours > $remainTimestamp)
239 {
240 $date += $multiplier < 0 ? -$remainTimestamp - 60 : $remainTimestamp + 60;
241 $date = $this->getNearestWorkTime($date, $multiplier) + (($hours - $remainTimestamp) * $multiplier);
242 }
243 else
244 {
245 $date += $multiplier * $hours;
246 }
247 }
248
249 $date -= $offset;
250
251 return new Bizproc\BaseType\Value\DateTime($date, $offset);
252 }
253
254 public function callAddWorkDays(Arguments $args)
255 {
256 $date = $args->getFirstSingle();
257 $offset = $this->getDateTimeOffset($date);
258 $days = (int)$args->getSecond();
259
260 if (($date = $this->makeTimestamp($date)) === false)
261 {
262 return null;
263 }
264
265 if ($days === 0 || !Main\Loader::includeModule('calendar'))
266 {
267 return $date;
268 }
269
270 $date = $this->addWorkDay($date, $days);
271
272 return new Bizproc\BaseType\Value\DateTime($date, $offset);
273 }
274
275 public function callIsWorkDay(Arguments $args)
276 {
277 if (!Main\Loader::includeModule('calendar'))
278 {
279 return false;
280 }
281
282 $date = $args->getFirstSingle();
283 $user = $args->getSecond();
284
285 if ($user)
286 {
287 $userArgs = clone $args;
288 $userArgs->setArgs([$user, $date]);
289
290 $date = $this->callToUserDate($userArgs);
291 }
292
293 if (($date = $this->makeTimestamp($date, true)) === false)
294 {
295 return false;
296 }
297
298 return !$this->isHoliday($date);
299 }
300
301 public function callIsWorkTime(Arguments $args)
302 {
303 if (!Main\Loader::includeModule('calendar'))
304 {
305 return false;
306 }
307
308 $date = $args->getFirstSingle();
309 $user = $args->getSecond();
310
311 if ($user)
312 {
313 $userArgs = clone $args;
314 $userArgs->setArgs([$user, $date]);
315
316 $date = $this->callToUserDate($userArgs);
317 }
318
319 if (($date = $this->makeTimestamp($date, true)) === false)
320 {
321 return false;
322 }
323
324 return !$this->isHoliday($date) && $this->isWorkTime($date);
325 }
326
327 public function callDateDiff(Arguments $args)
328 {
329 $date1 = $args->getFirstSingle();
330 $date2 = $args->getSecondSingle();
331 $format = $args->getThird();
332
333 if (!$date1 || !$date2 || !is_scalar($format))
334 {
335 return null;
336 }
337
338 $date1Formatted = $this->getDateTimeObject($date1);
339 $date2Formatted = $this->getDateTimeObject($date2);
340
341 if ($date1Formatted === false || $date2Formatted === false)
342 {
343 return null;
344 }
345
346 $interval = $date1Formatted->diff($date2Formatted);
347
348 return $interval === false ? null : $interval->format($format);
349 }
350
351 public function callDate(Arguments $args)
352 {
353 $format = $args->getFirst();
354 $date = $args->getSecondSingle();
355
356 if (!$format || !is_string($format))
357 {
358 return null;
359 }
360
361 $ts = $date ? $this->makeTimestamp($date, true) : time();
362
363 if (!$ts)
364 {
365 return null;
366 }
367
368 return date($format, $ts);
369 }
370
371 public function callToUserDate(Arguments $args)
372 {
373 $user = $args->getFirst();
374 $date = $args->getSecondSingle();
375
376 if (!$user)
377 {
378 return null;
379 }
380
381 if (!$date)
382 {
383 $date = time();
384 }
385 elseif (($date = $this->makeTimestamp($date)) === false)
386 {
387 return null;
388 }
389
390 $userId = \CBPHelper::extractFirstUser($user, $args->getParser()->getActivity()->getDocumentId());
391 $offset = $userId ? \CTimeZone::GetOffset($userId, true) : 0;
392
393 return new Bizproc\BaseType\Value\DateTime($date, $offset);
394 }
395
396 public function callGetUserDateOffset(Arguments $args)
397 {
398 $user = $args->getFirst();
399
400 if (!$user)
401 {
402 return null;
403 }
404
405 $userId = \CBPHelper::extractFirstUser($user, $args->getParser()->getActivity()->getDocumentId());
406
407 if (!$userId)
408 {
409 return 0;
410 }
411
412 return \CTimeZone::GetOffset($userId, true);
413 }
414
415 public function callStrtotime(Arguments $args)
416 {
417 $datetime = $args->getFirstSingle();
418 $baseDate = $args->getSecondSingle();
419
420 $baseTimestamp = $baseDate ? $this->makeTimestamp($baseDate, true) : time();
421
422 if (!$baseTimestamp || !is_scalar($datetime))
423 {
424 return null;
425 }
426
427 $timestamp = strtotime($datetime, (int)$baseTimestamp);
428
429 if ($timestamp === false)
430 {
431 return null;
432 }
433
434 return new Bizproc\BaseType\Value\DateTime($timestamp);
435 }
436
437 public function callLocDate(Arguments $args)
438 {
439 $format = $args->getFirst();
440 $date = $args->getSecondSingle();
441
442 if (!$format || !is_string($format))
443 {
444 return null;
445 }
446
447 $reformFormat = $this->frameSymbolsInDateFormat($format);
448 $timestamp = $date ? $this->makeTimestamp($date, true) : time();
449
450 if (!$timestamp)
451 {
452 return null;
453 }
454
455 $formattedDate = date($reformFormat, $timestamp);
456 // return \FormatDate($format, $timestamp); - TODO
457 if ($formattedDate === false)
458 {
459 return null;
460 }
461
462 return $this->replaceDateToLocDate($formattedDate, $reformFormat);
463 }
464
465 public function callSetTime(Arguments $args)
466 {
467 $date = $args->getFirstSingle();
468 $offset = $this->getDateTimeOffset($date);
469
470 $hour = max(0, (int)$args->getSecondSingle());
471 $minute = max(0, (int)$args->getThirdSingle());
472
473 if (($date = $this->makeTimestamp($date, true)) === false)
474 {
475 return null;
476 }
477
478 $dateTime = Main\Type\DateTime::createFromTimestamp($date);
479 $dateTime->setTime($hour, $minute, 0, 0);
480
481 $date = $dateTime->getTimestamp() - $offset;
482
483 return new Bizproc\BaseType\Value\DateTime($date, $offset);
484 }
485
486 private function makeTimestamp($date, $appendOffset = false)
487 {
488 if (!$date || (!is_scalar($date) && !is_object($date)))
489 {
490 return false;
491 }
492
493 //serialized date string
494 if (is_string($date) && Bizproc\BaseType\Value\Date::isSerialized($date))
495 {
496 $date = new Bizproc\BaseType\Value\Date($date);
497 }
498
499 if ($date instanceof Bizproc\BaseType\Value\Date)
500 {
501 return $date->getTimestamp() + ($appendOffset ? $date->getOffset() : 0);
502 }
503
504 if (intval($date) . "!" === $date . "!")
505 {
506 return $date;
507 }
508
509 if (($result = MakeTimeStamp($date, FORMAT_DATETIME)) === false)
510 {
511 if (($result = MakeTimeStamp($date, FORMAT_DATE)) === false)
512 {
513 if (($result = MakeTimeStamp($date, "YYYY-MM-DD HH:MI:SS")) === false)
514 {
515 $result = MakeTimeStamp($date, "YYYY-MM-DD");
516 }
517 }
518 }
519 return $result;
520 }
521
522 private function getWorkDayTimestamp($date)
523 {
524 return date('H', $date) * 3600 + date('i', $date) * 60;
525 }
526
527 private function getWorkDayRemainTimestamp($date, $multiplier = 1)
528 {
529 $dayTs = $this->getWorkDayTimestamp($date);
530 [$startSeconds, $endSeconds] = $this->getCalendarWorkTime();
531 return $multiplier < 0 ? $dayTs - $startSeconds : $endSeconds - $dayTs;
532 }
533
534 private function getWorkDayInterval()
535 {
536 [$startSeconds, $endSeconds] = $this->getCalendarWorkTime();
537 return $endSeconds - $startSeconds;
538 }
539
540 private function isHoliday($date)
541 {
542 [$yearWorkdays] = $this->getCalendarWorkdays();
543 [$weekHolidays, $yearHolidays] = $this->getCalendarHolidays();
544
545 $dayOfYear = date('j.n', $date);
546 if (in_array($dayOfYear, $yearWorkdays, true))
547 {
548 return false;
549 }
550
551 $dayOfWeek = date('w', $date);
552 if (in_array($dayOfWeek, $weekHolidays))
553 {
554 return true;
555 }
556
557 $dayOfYear = date('j.n', $date);
558 if (in_array($dayOfYear, $yearHolidays, true))
559 {
560 return true;
561 }
562
563 return false;
564 }
565
566 private function isWorkTime($date)
567 {
568 $dayTs = $this->getWorkDayTimestamp($date);
569 [$startSeconds, $endSeconds] = $this->getCalendarWorkTime();
570 return ($dayTs >= $startSeconds && $dayTs <= $endSeconds);
571 }
572
573 private function getNearestWorkTime($date, $multiplier = 1)
574 {
575 $reverse = $multiplier < 0;
576 [$startSeconds, $endSeconds] = $this->getCalendarWorkTime();
577 $dayTimeStamp = $this->getWorkDayTimestamp($date);
578
579 if ($this->isHoliday($date))
580 {
581 $date -= $dayTimeStamp;
582 $date += $reverse ? -86400 + $endSeconds : $startSeconds;
583 $dayTimeStamp = $reverse ? $endSeconds : $startSeconds;
584 }
585
586 if (!$this->isWorkTime($date))
587 {
588 $date -= $dayTimeStamp;
589
590 if ($dayTimeStamp < $startSeconds)
591 {
592 $date += $reverse ? -86400 + $endSeconds : $startSeconds;
593 }
594 else
595 {
596 $date += $reverse ? $endSeconds : 86400 + $startSeconds;
597 }
598 }
599
600 if ($this->isHoliday($date))
601 {
602 $date = $this->addWorkDay($date, $reverse ? -1 : 1);
603 }
604
605 return $date;
606 }
607
608 private function addWorkDay($date, $days)
609 {
610 $delta = 86400;
611 if ($days < 0)
612 {
613 $delta *= -1;
614 }
615
616 $days = abs($days);
617 $iterations = 0;
618
619 while ($days > 0 && $iterations < 1000)
620 {
621 ++$iterations;
622 $date += $delta;
623
624 if ($this->isHoliday($date))
625 {
626 continue;
627 }
628 --$days;
629 }
630
631 return $date;
632 }
633
634 private function getCalendarHolidays()
635 {
636 if (static::$yearHolidays === null)
637 {
638 $calendarSettings = \CCalendar::GetSettings();
639 $weekHolidays = [0, 6];
640 $yearHolidays = [];
641
642 if (isset($calendarSettings['week_holidays']))
643 {
644 $weekDays = ['SU' => 0, 'MO' => 1, 'TU' => 2, 'WE' => 3, 'TH' => 4, 'FR' => 5, 'SA' => 6];
645 $weekHolidays = [];
646 foreach ($calendarSettings['week_holidays'] as $day)
647 {
648 $weekHolidays[] = $weekDays[$day];
649 }
650 }
651
652 if (isset($calendarSettings['year_holidays']))
653 {
654 foreach (explode(',', $calendarSettings['year_holidays']) as $yearHoliday)
655 {
656 $date = explode('.', trim($yearHoliday));
657 if (count($date) == 2 && $date[0] && $date[1])
658 {
659 $yearHolidays[] = (int)$date[0] . '.' . (int)$date[1];
660 }
661 }
662 }
663 static::$weekHolidays = $weekHolidays;
664 static::$yearHolidays = $yearHolidays;
665 }
666
667 return [static::$weekHolidays, static::$yearHolidays];
668 }
669
670 private function getCalendarWorkTime()
671 {
672 if (static::$startWorkDay === null)
673 {
674 $startSeconds = 0;
675 $endSeconds = 24 * 3600 - 1;
676
677 $calendarSettings = \CCalendar::GetSettings();
678 if (!empty($calendarSettings['work_time_start']))
679 {
680 $time = explode('.', $calendarSettings['work_time_start']);
681 $startSeconds = $time[0] * 3600;
682 if (!empty($time[1]))
683 {
684 $startSeconds += $time[1] * 60;
685 }
686 }
687
688 if (!empty($calendarSettings['work_time_end']))
689 {
690 $time = explode('.', $calendarSettings['work_time_end']);
691 $endSeconds = $time[0] * 3600;
692 if (!empty($time[1]))
693 {
694 $endSeconds += $time[1] * 60;
695 }
696 }
697 static::$startWorkDay = $startSeconds;
698 static::$endWorkDay = $endSeconds;
699 }
700 return [static::$startWorkDay, static::$endWorkDay];
701 }
702
703 private function getCalendarWorkdays()
704 {
705 if (static::$yearWorkdays === null)
706 {
707 $yearWorkdays = [];
708
709 $calendarSettings = \CCalendar::GetSettings();
710 $calendarYearWorkdays = $calendarSettings['year_workdays'] ?? '';
711
712 foreach (explode(',', $calendarYearWorkdays) as $yearWorkday)
713 {
714 $date = explode('.', trim($yearWorkday));
715 if (count($date) === 2 && $date[0] && $date[1])
716 {
717 $yearWorkdays[] = (int)$date[0] . '.' . (int)$date[1];
718 }
719 }
720
721 static::$yearWorkdays = $yearWorkdays;
722 }
723
724 return [static::$yearWorkdays];
725 }
726
727 private function getDateTimeObject($date)
728 {
729 if ($date instanceof Bizproc\BaseType\Value\Date)
730 {
731 return (new \DateTime())->setTimestamp($date->getTimestamp());
732 }
733 elseif (is_array($date))
734 {
735 $date = \CBPHelper::flatten($date);
736 }
737
738 if (!is_scalar($date))
739 {
740 return false;
741 }
742
743 $df = Main\Type\DateTime::getFormat();
744 $df2 = Main\Type\Date::getFormat();
745 $date1Formatted = \DateTime::createFromFormat($df, $date);
746 if ($date1Formatted === false)
747 {
748 $date1Formatted = \DateTime::createFromFormat($df2, $date);
749 if ($date1Formatted)
750 {
751 $date1Formatted->setTime(0, 0);
752 }
753 }
754 return $date1Formatted;
755 }
756
757 private function getDateTimeOffset($date)
758 {
759 if ($date instanceof Bizproc\BaseType\Value\Date)
760 {
761 return $date->getOffset();
762 }
763
764 return 0;
765 }
766
767 private function frameSymbolsInDateFormat($format)
768 {
769 $complexSymbols = ['j F', 'd F', 'jS F'];
770 $symbols = ['D', 'l', 'F', 'M', 'r'];
771
772 $frameRule = [];
773 foreach ($symbols as $symbol)
774 {
775 $frameRule[$symbol] = '#' . $symbol . '#';
776 $frameRule['\\' . $symbol] = '\\' . $symbol;
777 }
778 foreach ($complexSymbols as $symbol)
779 {
780 $frameRule[$symbol] = substr($symbol, 0, -1) . '#' . $symbol[-1] . '_1#';
781 $frameRule['\\' . $symbol] = '\\' . substr($symbol, 0, -1) . '#' . $symbol[-1] . '#';
782 }
783
784 return strtr($format, $frameRule);
785 }
786
787 private function frameNamesInFormattedDateRFC2822($formattedDate)
788 {
789 $matches = [];
790 $pattern = "/#(\w{3}), \d{2} (\w{3}) \d{4} \d{2}:\d{2}:\d{2} [+-]\d{4}#/";
791 if (preg_match_all($pattern, $formattedDate, $matches))
792 {
793 foreach ($matches[0] as $key => $match)
794 {
795 $day = $matches[1][$key];
796 $month = $matches[2][$key];
797
798 $reformMatch = str_replace(
799 [$day, $month],
800 ['#' . $day . '#', '#' . $month . '#'],
801 $match
802 );
803 $reformMatch = substr($reformMatch, 1, -1);
804
805 $formattedDate = str_replace($match, $reformMatch, $formattedDate);
806 }
807 }
808
809 return $formattedDate;
810 }
811
812 private function replaceDateToLocDate($formattedDate, $format)
813 {
814 $lenShortName = 3;
815 $dayNames = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
816 $monthNames = [
817 'January',
818 'February',
819 'March',
820 'April',
821 'May',
822 'June',
823 'July',
824 'August',
825 'September',
826 'October',
827 'November',
828 'December',
829 ];
830
831 if (strpos($format, '#r#') !== false)
832 {
833 $formattedDate = $this->frameNamesInFormattedDateRFC2822($formattedDate);
834 }
835
836 $replacementRule = [];
837 foreach (array_merge($dayNames, $monthNames) as $name)
838 {
839 $replacementRule['#' . $name . '#'] = Loc::getMessage(
840 'BIZPROC_CALC_FUNCTION_LOCDATE_' . strtoupper($name)
841 );
842 $shortName = substr($name, 0, $lenShortName);
843 $replacementRule['#' . $shortName . '#'] = Loc::getMessage(
844 'BIZPROC_CALC_FUNCTION_LOCDATE_' . strtoupper($shortName) . '_SHORT'
845 );
846 }
847 foreach ($monthNames as $monthName)
848 {
849 $replacementRule['#' . $monthName . '_1' . '#'] = Loc::getMessage(
850 'BIZPROC_CALC_FUNCTION_LOCDATE_' . strtoupper($monthName) . '_1'
851 );
852 }
853
854 return strtr($formattedDate, $replacementRule);
855 }
856}
callDateDiff(Arguments $args)
Definition DateLib.php:327
callIsWorkDay(Arguments $args)
Definition DateLib.php:275
callWorkDateAdd(Arguments $args)
Definition DateLib.php:156
callGetUserDateOffset(Arguments $args)
Definition DateLib.php:396
callToUserDate(Arguments $args)
Definition DateLib.php:371
callDateAdd(Arguments $args)
Definition DateLib.php:84
callAddWorkDays(Arguments $args)
Definition DateLib.php:254
callStrtotime(Arguments $args)
Definition DateLib.php:415
callIsWorkTime(Arguments $args)
Definition DateLib.php:301
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29