Noon in Which Timezone? — Python Bug Hunt
Inspired by the countless "meeting at noon" disasters of naive timestamp handling.
- Language: Python
- Layer: Backend
- Difficulty: Medium
- Concepts: Timezones, Parsing
- Modelled on: Calendar apps
- Visible tests: positive offsets subtract; negative offsets add; wrapping past midnight stays in range
- Reward: 50 XP for a complete fix
Incident
- Severity: SEV-2 (priority: High)
- Ticket: BUG-TZ-NAIVE
- Reported by: scheduling
- Time to fix: 20 minutes, the target for a medium incident
Failing checks on the shipped build
- positive offsets subtract — expected 390 but got 720
- negative offsets add — expected 780 but got 540
- wrapping past midnight stays in range — expected 1395 but got 15
How to work this incident
- Read the report: write down the expected behaviour and the actual one in a sentence each.
- Reproduce it: run the visible tests and find the failing check that matches the report.
- Read the logs and the failing checks for the first value that is wrong — the earliest wrong value is nearer the cause than the loudest error.
- Follow the request through the handler, the validation and the service it calls; find the first step whose output disagrees with the report.
- Fix the cause rather than the symptom, run the visible tests again, and submit against the hidden ones — then write the root cause down.
Briefing
Inspired by the countless "meeting at noon" disasters of naive timestamp handling. Feeds send wall-clock times WITH their UTC offset — and the parser throws the offset away, so 12:00 in Mumbai and 12:00 in New York collide.
clocktime.py normalises "HH:MM±OH:OM" to minutes-since-midnight UTC.
Bug report
BUG-TZ-NAIVE · Priority: High · Reported by: scheduling
to_utc_minutes(stamp):
- "12:00+05:30" -> 390 (12:00 IST is 06:30 UTC)
- "09:00-04:00" -> 780 (09:00 EDT is 13:00 UTC)
- wrap into [0, 1440)
Observed: the offset part is ignored entirely.
Logs
[sched] "12:00+05:30" == "12:00-04:00" -> double-booked roomThe code as shipped
src/time/clocktime.py (editable)
# Normalises "HH:MM+OH:OM" (or -OH:OM) to minutes since midnight UTC.
def to_utc_minutes(stamp):
hh = int(stamp[0:2])
mm = int(stamp[3:5])
return hh * 60 + mm
Open the hunt to start the incident clock, edit the files, run the visible tests and submit against the hidden ones, then write the root cause down. More Python bug hunts.