Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
excludeddatescollection.php
1<?php
2
4
7
8
10{
11 public const EXCLUDED_DATE_FORMAT = 'd.m.Y';
12
17 public function toString(string $separator = ';'): string
18 {
19 return implode(
20 $separator,
21 array_unique(
22 array_map(
23 fn (Date $date) => $date->format(\CCalendar::DFormat(false)),
24 $this->collection)
25 ));
26 }
27
32 public function getDateCollectionNewerThanInterval(string $interval = '1 month'): ExcludedDatesCollection
33 {
34 $timestamp = (new Date())->sub($interval)->getTimestamp();
35
36 $exdateCollection = new static();
37
39 foreach ($this->collection as $item)
40 {
41 if ($item->getTimestamp() > $timestamp)
42 {
43 $exdateCollection->add($item);
44 }
45 }
46
47 return $exdateCollection;
48 }
49
54 public function removeDateFromCollection(Date $date): void
55 {
60 foreach ($this->collection as $key => $item)
61 {
62 if ($item->format('d.m.Y') === $date->format('d.m.Y'))
63 {
64 unset($this->collection[$key]);
65 }
66 }
67 }
68}
format(string $format=null)
Definition date.php:107