As with every other leap year, we have had some curious stories about leap year bugs. While you might be thinking about how something that is so foreseeable brings issues, I’d say that the lack of awareness on the complexity of the subject is what gets you.
There’s a saying that goes like this: «You should be respectful of the sea, but not afraid.» As far as I’m concerned, the same thing applies to times, time zones, or durations in software.
Much like a calm sea can turn into a death trap, every time that you get near anything that involves time, time zones, or durations, you should assume that the challenge you are facing, even if small, can turn out to be a disaster very rapidly and very unexpectedly.
I had thought to write on some of the things that have kept me afloat so far.
Fully understand the essentials
While this might seem a bit silly, there is a lot to it. This page actually exists: Falsehoods Programmers Believe About Time – FalsehoodsAboutTime.com. Don’t miss the second part!
While all languages usually include decent documentation about it, I think Python has an edge in using it to understand the subject. Semantics help a lot, and it’s quite easy to launch an interpreter.
You should be able to understand everything in that page, so dig deeper if needed. The Gregorian calendar, ISO 8601, POSIX timestamp, timezone, UTC, DST are just a few.
The most important thing to understand for me is that a moment has different time representations.
Use established libraries or OS tools
Keep in mind that the problem you are facing has probably been faced a multitude of times before. There is a battle-tested data type or operator waiting for you to be used.
Don’t go around calculating time differences and risking lives unnecessary.
Tom Scott has a great video on this.
If in problems, don’t panic
Sure enough, you might end up in some problem. While you should immediately ask for help when possible, you can usually work your way out of it if you keep your calm and proceed with caution.
Read what’s available in the platform you are using. Understand and validate what data you have to deal with. Keep in mind that localization does play a role in visualization. Check that you are backing up data. Validate assumptions for even silly things.
And focus on your breathing! 🏊

Una respuesta a “Treat time data like the sea 🌊”
[…] un post sobre esto en inglés hace un tiempo, así que voy a evitar repetirme. Diría que es el menos violento de los problemas y […]
Me gustaMe gusta