The three types of time

published on 2024/02/04

Handling dates and times in code can be tricky. Understanding that there are three types of time, that play by different rules, can help prevent bugs and ensure your code behaves as intended.

Before I describe these three types of time, let’s warm up with a riddle.

Alice and Bob were born at the exact same moment in time, in neighbouring towns somewhere in Florida. They met in school and immediately bonded over the fact that they had existed for the exact same number of seconds. Their love — naturally — flourished, and many years later, Bob took Alice out to a fancy dinner and proposed. She thought about it for a full 30 seconds before finally saying “sure”. The waiter overheard and wasted no time in suggesting some Champagne. “I’m afraid that’s against the rules”, said Alice, “I’m 21 but Bob is only 20”.

David Gilbertson