Live data from Hacker News

Insane complexity of calendrically correct date and time operations

yourcalendricalfallacyis.com

1–10 of 146 posts

Re: Insane complexity of calendrically correct date and time operations

#3
post #2

Is it true that Unix time is as simple as it seems? Is there exactly one second between adjacent integers? Do all Unix time values occur only once simultaneously around the world?

No, because unix times can repeat in the case of leap-seconds (this is necessary to be able to represent future times correctly).

Re: Insane complexity of calendrically correct date and time operations

#4
post #2

Is it true that Unix time is as simple as it seems? Is there exactly one second between adjacent integers? Do all Unix time values occur only once simultaneously around the world?

What you want is probably TAI [1], Unix Time has leap seconds.

[1] https://en.wikipedia.org/wiki/International_Atomic_Time

Re: Insane complexity of calendrically correct date and time operations

#6
post #2

Is it true that Unix time is as simple as it seems? Is there exactly one second between adjacent integers? Do all Unix time values occur only once simultaneously around the world?

Unix time depends on the wall clock time, so it is a wall clock time, so it can jump around arbitrarily when the computer clock is adjusted, and its seconds can be stretched as needed for gliding adjustments. Applications need to cope with that.

Re: Insane complexity of calendrically correct date and time operations

#8
post #3
post #2

Is it true that Unix time is as simple as it seems? Is there exactly one second between adjacent integers? Do all Unix time values occur only once simultaneously around the world?

No, because unix times can repeat in the case of leap-seconds (this is necessary to be able to represent future times correctly).

You can avoid repetitions by using clock_gettime(CLOCK_MONOTONIC, …).

Re: Insane complexity of calendrically correct date and time operations

#10
post #7

Many of these make the weird assumption that you want to support multiple calendars. For better or worse, this is rarely the case.

Yes, or that you care about historical aspects.

If we go on a far enough time scale, all calendars are constructed abstractions so theoretically nothing about them is true, but I'm not sure what's the point of that.

Post reply on HN