Skip to content

Commit c5aeb3b

Browse files
authored
Fix current timeline for times between 11:45 pm and 11:59 pm (#368)
Use the current timestamp rounded to the nearest thirty minutes to take a diff to the day's start at 12 am. Use the `past hours * 2` plus 1 if the half hour is past to align the clock correctly. If the rounded current time is 12 am at the next day the diff will return **0 past hours**, but **1 past day**. For this case we will multiply the past days by **24**. Fix #367
1 parent f5366e5 commit c5aeb3b

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

library/Notifications/Widget/Timeline.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,11 +371,12 @@ protected function assemble()
371371
);
372372

373373
$now = Util::roundToNearestThirtyMinute($now);
374+
$diff = $this->start->diff($now);
374375

375376
$this->getStyle()->addFor($currentTime, [
376377
'--timeStartColumn' =>
377-
$now->format('G') * 2 // 2 columns per hour
378-
+ ($now->format('i') >= 30 ? 1 : 0) // 1 column for the half hour
378+
($diff->d * 24 + $diff->h) * 2 // 2 columns per hour
379+
+ ($diff->i >= 30 ? 1 : 0) // 1 column for the half hour
379380
+ 1 // CSS starts counting columns from 1, not zero
380381
]);
381382

0 commit comments

Comments
 (0)