Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I'm pretty sure UTC is monotonic too, its unix timestamps that really are the true mess



Yeah you are right, when a leap second is introduced it becomes 23:59:60 (monotonic) in utc, while with unix-time a normal way to handle it is to repeat 23:59:59 twice (non-monotonic).


Leap seconds can be negative.


A negative leap second means that 23:59:59 is skipped, you go from 23:59:58 to 00:00:00, which is monotonically increasing, in both UTC and unixtime.

Positive leap seconds are monotonically increasing in UTC, where you get 23:59:60 between 23:59:59 and 00:00:00, but not in typical implementations of unix time where 23:59:59 repeats, and with milliseconds you go (breifly) 58.999 -> 59.0 -> 59.999 -> 59.0 -> 59.999 -> 0.0

If you're only counting seconds, then both UTC and unixtime are always monotonically increasing.


Wrong. The very topic of this discussion, leap seconds, are non-monotonic adjustments to UTC.


UTC is monotonic, even during leap seconds. (A positive leap second adds a 23:59:60; no timestamp ever repeats, the clock never moves backwards.)

(Negative leap seconds are similar, and do not affect the monotonic property.)

POSIX/Unix timestamps, however, are non-monotonic. But that's a different timescale.


In what way are leap seconds non-monotonic in UTC?




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: