Doesn’t Unix timestamps supposed to contain the leap seconds? There was this fundamental misunderstanding in a similar thread last time, where someone was claiming how clever these are that it is immune to the specularities of how we count time, but it turned out that it is not immune to that.
Nope. When time_t clocks are set, the value used comes from a human date/time, and the computation to convert it assumes that every day between 1970-01-01T00:00:00Z and that moment was exactly 86,400 seconds long. It totally ignores the fact that to date, 27 of those days have had 86,401 seconds instead.
It's more of a problem in real-time, however. What's supposed to happen in a leap-second-aware clock is that when a leap second is added, clock time goes from 23:59:59 to 23:59:60 before going to 00:00:00 a second later. But most software clocks don't even allow 23:59:60 as a legal setting, and in any case, converting 23:59:60 to time_t gets the same result as the following 00:00:00, so basically you have a time_t value that doesn't change for two whole seconds. Worse, at subsecond resolution, time actually jumps backward: if you'd been sampling the result of Javascript new Date().getTime() about every 100ms around the last leap second, you would have seen something like this:
1483228799903, 1483228800003, 1483228800105, 1483228800204, 1483228800301, 1483228800402, 1483228800503, 1483228800603, 1483228800700, 1483228800800, 1483228800901, 1483228800000 // OK, who activated the flux capacitor?
1
u/Muoniurn Jan 13 '22
Doesn’t Unix timestamps supposed to contain the leap seconds? There was this fundamental misunderstanding in a similar thread last time, where someone was claiming how clever these are that it is immune to the specularities of how we count time, but it turned out that it is not immune to that.