|
6 | 6 |
|
7 | 7 | use DateInterval; |
8 | 8 | use DateTime; |
| 9 | +use DateTimeZone; |
9 | 10 | use Generator; |
10 | 11 | use Icinga\Exception\ConfigurationError; |
11 | 12 | use Icinga\Exception\Http\HttpNotFoundException; |
12 | 13 | use Icinga\Module\Notifications\Common\Database; |
13 | 14 | use Icinga\Module\Notifications\Model\Contact; |
14 | 15 | use Icinga\Module\Notifications\Model\Contactgroup; |
15 | 16 | use Icinga\Module\Notifications\Model\Rotation; |
| 17 | +use Icinga\Module\Notifications\Model\Schedule; |
16 | 18 | use Icinga\Module\Notifications\Model\TimeperiodEntry; |
17 | 19 | use Icinga\Util\Json; |
18 | 20 | use Icinga\Web\Session; |
@@ -1145,7 +1147,8 @@ function ($value, $validator) use ($earliestHandoff, $firstHandoff, $latestHando |
1145 | 1147 | (new \IntlDateFormatter( |
1146 | 1148 | \Locale::getDefault(), |
1147 | 1149 | \IntlDateFormatter::MEDIUM, |
1148 | | - \IntlDateFormatter::SHORT |
| 1150 | + \IntlDateFormatter::SHORT, |
| 1151 | + $this->getScheduleTimezone() |
1149 | 1152 | ))->format($actualFirstHandoff) |
1150 | 1153 | ); |
1151 | 1154 | } |
@@ -1270,7 +1273,8 @@ private function parseDateAndTime(?string $date = null, ?string $time = null): D |
1270 | 1273 | return (new DateTime())->setTime(0, 0); |
1271 | 1274 | } |
1272 | 1275 |
|
1273 | | - $datetime = DateTime::createFromFormat($format, $expression); |
| 1276 | + $datetime = DateTime::createFromFormat($format, $expression, new DateTimeZone($this->getScheduleTimezone())); |
| 1277 | + |
1274 | 1278 | if ($datetime === false) { |
1275 | 1279 | $datetime = (new DateTime())->setTime(0, 0); |
1276 | 1280 | } elseif ($time === null) { |
@@ -1665,4 +1669,17 @@ public function hasChanges(): bool |
1665 | 1669 |
|
1666 | 1670 | return ! empty(array_udiff_assoc($values, $dbValuesToCompare, $checker)); |
1667 | 1671 | } |
| 1672 | + |
| 1673 | + /** |
| 1674 | + * Get the timezone of the schedule |
| 1675 | + * |
| 1676 | + * @return string The timezone identifier |
| 1677 | + */ |
| 1678 | + protected function getScheduleTimezone(): string |
| 1679 | + { |
| 1680 | + return Schedule::on(Database::get()) |
| 1681 | + ->filter(Filter::equal('id', $this->scheduleId)) |
| 1682 | + ->first() |
| 1683 | + ->timezone; |
| 1684 | + } |
1668 | 1685 | } |
0 commit comments