Back tostdlib
Blog Post
New

Falsehoods programmers believe about time: @noahsussman: Infinite Undo

Time handling is riddled with gotchas that break production code. Weeks span years, minutes last hours, and your system clock lies. Here are the common misconceptions that cause real bugs.

Time handling in software is not just about daylight savings. It's about fundamental misconceptions that cause production bugs, test failures, and data corruption. A week can begin in one year and end in another. A minute on your system clock can genuinely last longer than an hour - not theoretically, but in actual production systems. Old KVM VMs would freeze their clocks when suspended, drifting hours or days behind real time until a cron job caught up.

The post catalogs dozens of false assumptions programmers make: that months always have 30 or 31 days (wrong - February exists), that any 24-hour period stays in the same day (wrong - DST transitions), that server and client clocks match (spectacularly wrong - they can differ by decades). These aren't academic edge cases. They're bugs the author found repeatedly while debugging test code and production systems. The timestamp that seems unique? Not guaranteed. The human-readable date format? Not universally understood.

What makes this valuable is the specificity. It doesn't explain how to fix these problems - it makes you aware they exist. When you write code that handles time, you now know to question every assumption. Does this work during a DST transition? What if the system clock is wrong? What if it's wrong by years? The KVM bug alone - where VMs lost time whenever they went idle - demonstrates how far reality diverges from programmer expectations. Your code probably has these bugs right now.

Source: infiniteundo.com
#software-engineering#testing#debugging#distributed-systems#technical-debt#date-time#edge-cases

Problems this helps solve:

Technical debtProcess inefficiencies

Explore more resources

Check out the full stdlib collection for more frameworks, templates, and guides to accelerate your technical leadership journey.