published · 2 min read

Tomorrow Is Not 24 Hours Away

OpenPack added a day in milliseconds to find tomorrow, and in Paris, for an hour next to midnight on the nights the clocks change, that lands on the wrong date.

Saturday 27 March 23:30 plus 24 hours equals Monday 29 March 00:30, because that Sunday has only 23 hours.
Paris, the night the clocks go forward.

An AI agent drafted this from my projects, agents ran the measurements, and another agent checked the draft claim by claim against the code and the run records or briefs that were kept. The projects and opinions are mine.

At 23:30 on Saturday 27 March 2027 in Paris, now + 86400000 lands at 00:30 on Monday, because that Sunday has only 23 hours. OpenPack, my indoor cycling game, used that sum to decide when a listed event says "Tomorrow":

if (day(startAt) === day(now + 86400000)) return `Tomorrow ${time}`;

day turns a timestamp into a calendar date string, and on most nights 24 hours from now falls on tomorrow's date. Pulled out of git and run on made-up events with TZ=Europe/Paris and LC_ALL=en_GB.UTF-8 on Node 22.23.2, since the date and time follow the locale, the versions of this function from before the fix and after it give these results:

A 24-hour bar starting at Saturday 23:30 runs across a 23-hour Sunday and ends at Monday 00:30; the old code then labels the Sunday event Sun 28 Mar 19:00 and the Monday event Tomorrow 19:00.
Twenty-four hours from Saturday 23:30 skips the short Sunday.
eve of spring forward     now Sat Mar 27 2027 | now+24h Mon Mar 29 2027 | event Sun Mar 28 2027
                          old: Sun 28 Mar 19:00   new: Tomorrow 19:00
same night, Monday event  now Sat Mar 27 2027 | now+24h Mon Mar 29 2027 | event Mon Mar 29 2027
                          old: Tomorrow 19:00   new: Mon 29 Mar 19:00
night clocks go back      now Sun Oct 25 2026 | now+24h Sun Oct 25 2026 | event Mon Oct 26 2026
                          old: Mon 26 Oct 07:00   new: Tomorrow 07:00
ordinary night            now Wed Jun 10 2026 | now+24h Thu Jun 11 2026 | event Thu Jun 11 2026
                          old: Tomorrow 19:00   new: Tomorrow 19:00

An agent pulled and ran both versions on 7 November 2026. Rows 1 and 3 are misses, where the list shows a full date and skips "Tomorrow". On a night when clocks go back, that day has 25 hours, so 24 hours from 00:30 is still Sunday. Row 2 is worse. There the old code calls a Monday event "Tomorrow" on a Saturday night. The repo's test covers rows 1 and 3, and the agent added that Monday case for this post.

Commit 9c361eb fixed it by asking the calendar for the next date in local time.

if (day(startAt) === new Date(today.getFullYear(), today.getMonth(), today.getDate() + 1).toDateString()) return `Tomorrow ${time}`;

Above that line there is a comment with the reason: "24 h on from late on the eve of a clock change is the day after". An answer to Stack Overflow's How to add days to Date? (2013) marks the same sum, days * 24 * 60 * 60 * 1000, "Bad during DST" and adds days with setDate instead.

As bugs go, it's a bit of a corner case. A minute-by-minute scan of 2026 and 2027 in Paris time puts the old sum wrong for 60 minutes on four dates, 23:00 to 23:59 on a Saturday before clocks go forward and 00:00 to 00:59 on a Sunday when they go back. Clock times would have stayed right, and only the word "Tomorrow" would have been off. None of those dates fell in the eight days that line was in the repo, 2 to 10 October 2026, so Paris never had a clock change for it to trip on. Sydney did: clocks there went forward on Sunday 4 October, so from 23:00 to 23:59 on Saturday the 3rd, adding 24 hours landed on Monday. Other zones move it around: in a coarser scan New York has the same two windows on its own dates, Cairo's fall on Thursdays, Lord Howe's last 30 minutes, and Tokyo has none.