Skip to content

Commit bb75f8d

Browse files
committed
Adjust timezones for experimental parts
1 parent 76863d7 commit bb75f8d

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

application/forms/RotationConfigForm.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,11 @@ public function loadRotation(int $rotationId): self
230230
throw new LogicException('Invalid mode');
231231
}
232232

233-
$handoff = DateTime::createFromFormat('Y-m-d H:i', $rotation->first_handoff . ' ' . $time);
233+
$handoff = DateTime::createFromFormat(
234+
'Y-m-d H:i',
235+
$rotation->first_handoff . ' ' . $time,
236+
new DateTimeZone($this->displayTimezone)
237+
);
234238
if ($handoff === false) {
235239
throw new ConfigurationError('Invalid date format');
236240
}
@@ -261,7 +265,9 @@ public function loadRotation(int $rotationId): self
261265
->orderBy('until_time', SORT_DESC)
262266
->first();
263267
if ($previousShift !== null) {
264-
$this->previousShift = $previousShift->until_time;
268+
$this->previousShift = $previousShift->until_time->setTimezone(
269+
new DateTimeZone($this->displayTimezone)
270+
);
265271
}
266272

267273
/** @var ?Rotation $newerRotation */
@@ -455,6 +461,9 @@ public function editRotation(int $rotationId): void
455461
->filter(Filter::equal('timeperiod.owned_by_rotation_id', $rotationId));
456462

457463
foreach ($timeperiodEntries as $timeperiodEntry) {
464+
$timeperiodEntry->start_time->setTimezone($this->getScheduleTimezone());
465+
$timeperiodEntry->end_time->setTimezone($this->getScheduleTimezone());
466+
458467
/** @var TimeperiodEntry $timeperiodEntry */
459468
$rrule = $timeperiodEntry->toRecurrenceRule();
460469
$shiftDuration = $timeperiodEntry->start_time->diff($timeperiodEntry->end_time);

library/Notifications/Widget/Timeline/Rotation.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,11 @@ public function getPriority(): int
8181
*/
8282
public function fetchTimeperiodEntries(DateTime $after, DateTime $until): Generator
8383
{
84+
$scheduleTimezone = new DateTimeZone($this->model->schedule->execute()->current()->timezone);
85+
8486
$actualHandoff = null;
8587
if (RotationConfigForm::EXPERIMENTAL_OVERRIDES) {
86-
$actualHandoff = $this->model->actual_handoff;
88+
$actualHandoff = $this->model->actual_handoff->setTimezone($scheduleTimezone);
8789
}
8890

8991
$entries = $this->model->timeperiod->timeperiod_entry
@@ -99,7 +101,6 @@ public function fetchTimeperiodEntries(DateTime $after, DateTime $until): Genera
99101
)
100102
));
101103
foreach ($entries as $timeperiodEntry) {
102-
$scheduleTimezone = new DateTimeZone($this->model->schedule->execute()->current()->timezone);
103104
$timeperiodEntry->start_time->setTimezone($scheduleTimezone);
104105
$timeperiodEntry->end_time->setTimezone($scheduleTimezone);
105106

0 commit comments

Comments
 (0)