Every program in our system showed the wrong name. Not some programs — every single one, for the first hour of every broadcast. We checked the code. We checked the database. We checked the schedule feed. Everything looked correct. The bug was invisible because it wasn't in any of those places.
It was in the clock.
The Setup
An international radio station recorded its programs in the cloud in one-hour chunks. Our job: fetch each recording, match it to the program schedule, and store it with the right metadata. The station operated in UTC+1. Our servers ran in UTC.
Program A ends at 6 AM station time. Program B starts at 6 AM. Our system pulls the 6-7 AM chunk and tags it as Program A — because on our server, that hour maps to 5-6 AM, which is still Program A's slot.
A one-hour offset. Every recording. Every day. The first hour of every program was mislabeled, and nobody noticed for weeks because the data looked right if you didn't think about timezones.
The Fix
Convert everything to UTC before comparing anything to anything. Don't convert at the edge. Don't convert when displaying. Convert at the moment data enters the system, and never look back.
// Get the audio file and the schedule
let audioFile = fetchAudioFromCloud();
let schedule = fetchSchedule();
// Get the timestamp of the audio file in UTC+1
let timestamp = audioFile.timestamp;
// Convert the timestamp to UTC
let timestampUTC = timestamp - 60000;
// Adjust the schedule time to UTC
schedule.forEach(program => {
program.startTime = program.startTime - 60000;
program.endTime = program.endTime - 60000;
});
// Find the program for the audio file
let program = schedule.find(p => timestampUTC >= p.startTime && timestampUTC < p.endTime);
// Create a new record with the program info and audio file
let record = {
programInfo: program.info,
audioFile: audioFile
};
// Save the record to the database
saveRecordToDatabase(record);
Once everything speaks UTC, the matching is trivial. The bug vanishes not because we fixed the comparison logic, but because we eliminated the condition that made it wrong.
What This Taught Me
Timezone bugs are the ghosts of software development. You won't find them by reading your code line by line, because your code is correct — it's the assumptions underneath that are broken. The timestamp says 6 AM but doesn't say whose 6 AM.
The frustration of debugging something that isn't in your code teaches you something no tutorial can: the system is bigger than your repository. Senior developers aren't people who write perfect code. They're people who've been burned enough times by external conditions — timezones, encoding, network partitions, floating point — that they've learned to question the environment, not just the logic.
When you get timezone handling right, it's music to your ears. When you get it wrong, you spend three days debugging a clock.
