Wrong one hour a year
Why it matters A bug that shows up for one hour a year survives every review and every test run on an ordinary day. The day it bites, your finance report is off and nobody can say why.
A shop counts orders per local calendar day for its UK report. Timestamps are stored as UTC seconds. The function is given offset_at(ts), which says how many seconds local time is ahead of UTC at a given instant (the starter has the UK rules for 2026).
An analyst found one order on the wrong day:
daily_counts([1774827000], uk_offset) # 2026-03-29 23:30 UTC
# expected {"2026-03-30": 1} (00:30 in the UK, clocks went forward that morning)
# got {"2026-03-29": 1}UTC offset: how far local clock time is from UTC at one instant. It belongs to the instant, not to the day: on the day clocks change, a day has two offsets.
Fix daily_counts(timestamps, offset_at) so each event is counted on its local calendar day. The hidden tests use every hour of 2026 with the UK rules, extra events around both UK clock changes (spring and autumn), and two other zones' rules passed in as offset_at, including one whose clocks change at a different time of day. Do not assume UK dates: use the offset_at you are given.
Spotted a problem in this lesson? Report it · Ask about this lesson
This exercise opens soon
Finish the lesson before it and this one unlocks. The whole course is free, no account needed, and you can read this lesson right now.
This browser is blocking cookies for learn.floati.life, so lessons you finished here cannot open in order. Allow cookies for this site and reload.