[nSLUG] posix time stamps

Eric R. Smith ersmith at hfx.eastlink.ca
Fri Jul 1 16:02:54 ADT 2011


Well, you learn something every day... I always thought that Posix time 
stamps specified the number of seconds elapsed since midnight Jan. 1, 
1970. But in fact they specify the number of "non leap-seconds" elapsed, 
and the Posix standard goes out of its way to define time_t so that 
every day must be exactly 86400 seconds long.

The trouble is that since 1972 leap seconds have been inserted (at 
irregular intervals) to keep atomic time and solar time in sync. As a 
result, some days are 86401 seconds long.

So programs which calculate elapsed time by subtracting time_t's will 
sometimes get the wrong answer. Moreover, files created during a leap 
second will have the same Posix time stamp as files created on the first 
second of the following day.

Ugh.

Eric

PS: Happy Canada Day!



More information about the nSLUG mailing list