Denshin / Blog / Engineering
The bug that made us stop trusting timestamps
A Sunday-afternoon double-booking incident, the timezone mismatch behind it, and the two house rules we wrote afterwards that have prevented it from happening again.
Denshin Engineering · Engineering Team · 14 February 2026 · 1 min read
This is a war story. A small one, but one we keep telling new hires.
A client called on a Sunday. Their booking system was double-booking rooms. The room would show as available at 11pm, a customer would complete the checkout, and another customer would also complete the checkout, and the second one would win, silently. Nobody got an error.
The relevant code was about 30 lines. It checked whether a booking overlapped any existing booking by comparing timestamps. The comparison looked perfectly reasonable.
The bug was that the timestamps weren't all in the same timezone. The booking handler was creating timestamps in UTC. The legacy migration script that imported a year of historical bookings had stored them in IST. The comparison was numerical and didn't care that one was five and a half hours offset from the other. Most of the time it didn't matter: the gap between bookings was big enough. On a busy weekend with back-to-back bookings, the math collapsed.
We fixed it in twenty minutes. The harder part was finding every other place in the codebase that compared timestamps without thinking. We added two rules:
- All timestamps stored in the database are ISO 8601 UTC strings. No exceptions, no offsets.
- All timestamp arithmetic happens through dayjs (or a similarly explicit library). No raw
new Date(x) - new Date(y).
The rules feel paranoid until the day a client calls you on a Sunday.
The deeper lesson, the one we tell new hires, is this: if you find yourself doing arithmetic on a value, ask one extra question: "what units is this in?" Numbers don't carry units. Timestamps look like numbers. Money looks like numbers. Distances look like numbers. They aren't.
Tags: Debugging, Timezones, Postmortem, War Story
All posts · Work with Denshin