Skip to content

Commit e90a1e5

Browse files
Fix incorrect flyout text (#396)
1 parent 8dde915 commit e90a1e5

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

library/Notifications/Widget/Timeline/EntryFlyout.php

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -275,12 +275,19 @@ protected function generateAndSetRotationInfo(): static
275275
);
276276
}
277277

278-
if ($dateFormatter->format(new DateTime()) < $firstHandoff) {
278+
$startTime = match ($this->mode) {
279+
'24-7' => $this->rotationOptions['at'],
280+
'partial' => $this->rotationOptions['from'],
281+
'multi' => $this->rotationOptions['from_at'],
282+
};
283+
284+
if (new DateTime() < DateTime::createFromFormat('Y-m-d H:i', $this->firstHandoff . ' ' . $startTime)) {
279285
$startText = $this->translate('Starts on %s');
280286
} else {
281287
$startText = $this->translate('Started on %s');
282288
}
283289

290+
$startTime = $timeFormatter->format(DateTime::createFromFormat('H:i', $startTime));
284291
$firstHandoffInfo = new HtmlElement(
285292
'span',
286293
Attributes::create(['class' => 'rotation-info-start']),
@@ -290,6 +297,11 @@ protected function generateAndSetRotationInfo(): static
290297
)
291298
);
292299

300+
if ($this->mode === "24-7") {
301+
// Include handoff daytime in 24-7 rotations
302+
$handoff .= sprintf($this->translate(' at %s'), $startTime);
303+
}
304+
293305
$handoffInterval = new HtmlElement(
294306
'span',
295307
Attributes::create(['class' => ['rotation-info-interval']]),
@@ -303,7 +315,6 @@ protected function generateAndSetRotationInfo(): static
303315

304316
if ($this->mode === "partial") {
305317
$days = $this->rotationOptions["days"];
306-
$from = $timeFormatter->format(DateTime::createFromFormat('H:i', $this->rotationOptions["from"]));
307318
$to = $timeFormatter->format(DateTime::createFromFormat('H:i', $this->rotationOptions["to"]));
308319
if ($days[count($days) - 1] - $days[0] === (count($days) - 1) && count($days) > 1) {
309320
$daysText = sprintf(
@@ -326,14 +337,13 @@ protected function generateAndSetRotationInfo(): static
326337
new HtmlElement(
327338
'span',
328339
Attributes::create(['class' => ['rotation-info-days']]),
329-
Text::create(sprintf('%s %s - %s, ', $daysText, $from, $to))
340+
Text::create(sprintf('%s %s - %s, ', $daysText, $startTime, $to))
330341
),
331342
$handoffInterval
332343
)
333344
)->addHtml($firstHandoffInfo);
334345
} elseif ($this->mode === "multi") {
335346
$fromDay = $weekdayNames[$this->rotationOptions["from_day"]];
336-
$fromAt = $timeFormatter->format(DateTime::createFromFormat('H:i', $this->rotationOptions["from_at"]));
337347
$toDay = $weekdayNames[$this->rotationOptions["to_day"]];
338348
$toAt = $timeFormatter->format(DateTime::createFromFormat('H:i', $this->rotationOptions["to_at"]));
339349

@@ -344,7 +354,7 @@ protected function generateAndSetRotationInfo(): static
344354
new HtmlElement(
345355
'span',
346356
Attributes::create(['class' => ['rotation-info-days']]),
347-
Text::create(sprintf('%s %s - %s %s, ', $fromDay, $fromAt, $toDay, $toAt))
357+
Text::create(sprintf('%s %s - %s %s, ', $fromDay, $startTime, $toDay, $toAt))
348358
),
349359
$handoffInterval
350360
)

0 commit comments

Comments
 (0)