@@ -95,40 +95,40 @@ |
||
| 95 | 95 | |
| 96 | 96 | public function isFollowUpDay(DateTimeInterface $dateTime, string $followUpDay): bool |
| 97 | 97 | { |
| 98 | - if ($dateTime instanceof DateTime) { |
|
| 99 | - $dateTime = DateTimeImmutable::createFromMutable($dateTime); |
|
| 100 | - } |
|
| 101 | - return $this->isModifiedDate($dateTime, $followUpDay, 'next'); |
|
| 98 | + if ($dateTime instanceof DateTime) { |
|
| 99 | + $dateTime = DateTimeImmutable::createFromMutable($dateTime); |
|
| 100 | + } |
|
| 101 | + return $this->isModifiedDate($dateTime, $followUpDay, 'next'); |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | public function isPreviousDay(DateTimeInterface $dateTime, string $previousDay): bool |
| 105 | 105 | { |
| 106 | - if ($dateTime instanceof DateTime) { |
|
| 107 | - $dateTime = DateTimeImmutable::createFromMutable($dateTime); |
|
| 108 | - } |
|
| 109 | - return $this->isModifiedDate($dateTime, $previousDay, 'previous'); |
|
| 106 | + if ($dateTime instanceof DateTime) { |
|
| 107 | + $dateTime = DateTimeImmutable::createFromMutable($dateTime); |
|
| 108 | + } |
|
| 109 | + return $this->isModifiedDate($dateTime, $previousDay, 'previous'); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - private function isModifiedDate(DateTimeImmutable $dateTime, string $modifiedDay, string $direction): bool |
|
| 113 | - { |
|
| 114 | - $cal = clone $this->calendar; |
|
| 115 | - $cal = self::setGregorianYearForDate((int) $dateTime->format('Y'), $cal); |
|
| 116 | - $day = $cal->toDateTime(); |
|
| 117 | - $day->modify($direction . ' ' . $modifiedDay); |
|
| 118 | - $cal->setTime($day->getTimestamp() * 1000); |
|
| 119 | - $cal2 = clone $this->calendar; |
|
| 120 | - $cal2->setTime($dateTime->getTimestamp() * 1000); |
|
| 121 | - |
|
| 122 | - if (null !== $this->year && $cal->get(IntlCalendar::FIELD_YEAR) !== $cal2->get(IntlCalendar::FIELD_YEAR)) { |
|
| 123 | - return false; |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - if ($cal->get(IntlCalendar::FIELD_MONTH) !== $cal2->get(IntlCalendar::FIELD_MONTH)) { |
|
| 127 | - return false; |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - return $cal->get(IntlCalendar::FIELD_DAY_OF_MONTH) === $cal2->get(IntlCalendar::FIELD_DAY_OF_MONTH); |
|
| 131 | - } |
|
| 112 | + private function isModifiedDate(DateTimeImmutable $dateTime, string $modifiedDay, string $direction): bool |
|
| 113 | + { |
|
| 114 | + $cal = clone $this->calendar; |
|
| 115 | + $cal = self::setGregorianYearForDate((int) $dateTime->format('Y'), $cal); |
|
| 116 | + $day = $cal->toDateTime(); |
|
| 117 | + $day->modify($direction . ' ' . $modifiedDay); |
|
| 118 | + $cal->setTime($day->getTimestamp() * 1000); |
|
| 119 | + $cal2 = clone $this->calendar; |
|
| 120 | + $cal2->setTime($dateTime->getTimestamp() * 1000); |
|
| 121 | + |
|
| 122 | + if (null !== $this->year && $cal->get(IntlCalendar::FIELD_YEAR) !== $cal2->get(IntlCalendar::FIELD_YEAR)) { |
|
| 123 | + return false; |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + if ($cal->get(IntlCalendar::FIELD_MONTH) !== $cal2->get(IntlCalendar::FIELD_MONTH)) { |
|
| 127 | + return false; |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + return $cal->get(IntlCalendar::FIELD_DAY_OF_MONTH) === $cal2->get(IntlCalendar::FIELD_DAY_OF_MONTH); |
|
| 131 | + } |
|
| 132 | 132 | |
| 133 | 133 | public function getWeekdayForGregorianYear(int $year): int |
| 134 | 134 | { |