@@ -80,6 +80,9 @@ class RotationConfigForm extends CompatForm
8080 /** @var int The rotation id */
8181 protected $ rotationId ;
8282
83+ /** @var string The timezone to display the timeline in */
84+ protected $ displayTimezone ;
85+
8386 /**
8487 * Set the label for the submit button
8588 *
@@ -187,11 +190,13 @@ public function hasBeenWiped(): bool
187190 *
188191 * @param int $scheduleId
189192 * @param Connection $db
193+ * @param string $displayTimezone
190194 */
191- public function __construct (int $ scheduleId , Connection $ db )
195+ public function __construct (int $ scheduleId , Connection $ db, string $ displayTimezone )
192196 {
193197 $ this ->db = $ db ;
194198 $ this ->scheduleId = $ scheduleId ;
199+ $ this ->displayTimezone = $ displayTimezone ;
195200 }
196201
197202 /**
@@ -1294,18 +1299,39 @@ private function parseDateAndTime(?string $date = null, ?string $time = null): D
12941299 */
12951300 private function getTimeOptions (): array
12961301 {
1302+ $ scheduleTimezone = $ this ->getScheduleTimezone ();
1303+
12971304 $ formatter = new \IntlDateFormatter (
12981305 \Locale::getDefault (),
12991306 \IntlDateFormatter::NONE ,
1300- \IntlDateFormatter::SHORT
1307+ \IntlDateFormatter::SHORT ,
1308+ $ scheduleTimezone ->getName ()
1309+ );
1310+
1311+ $ dtzFormatter = new \IntlDateFormatter (
1312+ \Locale::getDefault (),
1313+ \IntlDateFormatter::NONE ,
1314+ \IntlDateFormatter::SHORT ,
1315+ $ this ->displayTimezone
13011316 );
13021317
13031318 $ options = [];
1304- $ dt = new DateTime ();
1319+ $ dt = new DateTime (' now ' , $ scheduleTimezone );
13051320 for ($ hour = 0 ; $ hour < 24 ; $ hour ++) {
13061321 for ($ minute = 0 ; $ minute < 60 ; $ minute += 30 ) {
13071322 $ dt ->setTime ($ hour , $ minute );
1308- $ options [$ dt ->format ('H:i ' )] = $ formatter ->format ($ dt );
1323+
1324+ if ($ this ->displayTimezone !== $ scheduleTimezone ->getName ()) {
1325+ $ dtzDt = (clone $ dt )->setTimezone (new DateTimeZone ($ this ->displayTimezone ));
1326+
1327+ $ options [$ dt ->format ('H:i ' )] = sprintf (
1328+ '%s (%s) ' ,
1329+ $ formatter ->format ($ dt ),
1330+ $ dtzFormatter ->format ($ dtzDt )
1331+ );
1332+ } else {
1333+ $ options [$ dt ->format ('H:i ' )] = $ formatter ->format ($ dt );
1334+ }
13091335 }
13101336 }
13111337
0 commit comments