Time - do you **really** understand it?

smart-watch-821557_640
( Image by fancycrave1 from Pixabay)

With fuel pumps in New Zealand left unable to take payment from customers yesterday (which was a leap day - 29 February 2024) due to a “software glitch” (see The Register), as an aspiring coder, how well do you think you understand how to work with time in your code?

Here’s a list of falsehoods that programmers tend to believe about working with time in computer code (full list in link below):

  • There are always 24 hours in a day.
  • February is always 28 days long.
  • Any 24-hour period will always begin and end in the same day (or week, or month).
  • A week always begins and ends in the same month.
  • A week (or a month) always begins and ends in the same year.
  • The machine that a program runs on will always be in the GMT time zone.
  • Ok, that’s not true. But at least the time zone in which a program has to run will never change.
  • Well, surely there will never be a change to the time zone in which a program hast to run in production.
  • The system clock will always be set to the correct local time.
  • The system clock will always be set to a time that is not wildly different from the correct local time.
  • If the system clock is incorrect, it will at least always be off by a consistent number of seconds.
  • The server clock and the client clock will always be set to the same time.
  • The server clock and the client clock will always be set to around the same time.
  • Ok, but the time on the server clock and time on the client clock would never be different by a matter of decades.
  • If the server clock and the client clock are not in synch, they will at least always be out of synch by a consistent number of seconds.
  • The server clock and the client clock will use the same time zone.
  • The system clock will never be set to a time that is in the distant past or the far future.

See more here.

6 Likes

I had no idea there were so many misconceptions about working with time in code! :open_mouth:

3 Likes

We got through the millenium bug at the turn of the century - now for the Year 2038 problem!

2 Likes

Jeez, things you learn! One second you think you understand how something works, and then find yourself faced with the fact that you had some misconceptions this whole time😅

It’s like a reminder that the digital world doesn’t always mirror the simplicity of our clocks and calendars.

this sounds super complicated omg! haha

wow it seems like there will always be a new problem to solve when it comes to code!