📜 ⬆️ ⬇️

Misconceptions of programmers about Unix-time

My apologies to Patrick McKenzie .

Yesterday, Danny inquired about curious facts about Unix-time, and I remembered that sometimes it works completely unintuitively.

These three facts seem extremely reasonable and logical, aren't they?
')
  1. Unix time is the number of seconds since January 1, 1970 00:00:00 UTC.
  2. If you wait exactly one second, the Unix time will change by exactly one second.
  3. Unix time never moves backwards.

All this is not true.

But it is not enough just to state “All this is not true,” without explaining why . See explanations below. But if you want to think for yourself, do not scroll the clock image!


Desk clock of the 1770s. Collected by John Leroux. From the Wellcome collection . Published under the CC BY license

All three misconceptions have one reason: leap seconds . If you are not familiar with the leap seconds, here is a quick reference:

UTC time is determined by two factors:


The problem is that these two numbers do not always match. The rotation of the Earth is not consistent - it gradually slows down, so the day in World time is getting longer. On the other hand, atomic clocks are devilishly accurate and constant over millions of years.

When two times fall out of sync, a second is added to or removed from UTC to return synchronization. Since 1972, the IERS service (which manages this case) has added 27 additional seconds. The result was 27 days UTC with a duration of 86,401 seconds. Theoretically, the appearance of a day of 86,399 seconds (minus one) is possible. Both options contradict the fundamental assumption about Unix-time.

Unix time assumes that each day lasts exactly 86,400 seconds (60 × 60 × 24 = 86,400), without any additional seconds. If such a jump occurs, the Unix time either jumps over in a second, or by counting two seconds in one. As of 2019, there are no 27 leap seconds in it.

So our delusions need to be added as follows:


This is probably not the only weird thing about Unix time - just what I remembered yesterday.

Time is a very strange thing.

Source: https://habr.com/ru/post/452584/


All Articles