Hacker News new | ask | show | jobs
by Someone1234 4006 days ago
I don't understand why either. Counting up from 1/1/1970 and then making adjustments for rendering only seems like a simple, reliable, and time tested solution.

I guess people don't want a database of leap seconds and a lookup each time time is rendered, but ultimately it seems like the best solution which is least likely to break things.

2 comments

Yeah. I'd like to see us all set our hardware clocks to TAI and everything else comes from the time zone files. It won't solve everything because lots of protocols have broken notions of time, but at least we could all agree on what the hardware time is supposed to mean and there would be no worry about leap seconds at that level.
The nice thing about time standards is that there are so many to choose from!

One drawback of your approach is that I can't just see if a time = 0 mod 60 to check if we are on a minute boundary.

Your way is what is used by the GPS network, IIRC, and it works for them, so there you go.

If your dates and times and locations vary enough, you already can't do a mod 60 check on UTC to detect a minute boundary, as various historical time zones include seconds-level offsets from UTC. For example, US cities were on local solar time until the latter part of the 19th century, and the changeover to uniform time zones involved lots of seconds-level offsets. Interesting stories here:

http://historymatters.gmu.edu/d/5748

I don't think anything to that resolution is in any time zone database, so you would be using a custom system anyway.
I just downloaded the standard ones from: https://www.iana.org/time-zones

It appears to have this stuff down to the second. For example:

    # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
    Zone America/New_York	-4:56:02 -	LMT	1883 Nov 18 12:03:58

    # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
    Zone America/Chicago	-5:50:36 -	LMT	1883 Nov 18 12:09:24
Although this won't really be accurate, because it doesn't have every single city. The New_York zone covers the whole eastern time zone even though all the cities in that zone would have been different before 1883. But it is in the database, even if it's not quite right for anything outside of the named cities.
Well that's a mess. Wrong data is worse than missing data for something like this...