Seconds from 19xx to Date (and visa versa)

Guy Harris guy at auspex.UUCP
Fri Oct 28 14:32:36 AEST 1988


>>     Does anyone have a routine to change back and forth between
>> seconds from 19xx to a Year, Month, Day sort of Date?
>
>You need more than a routine to do this.  You need a database of when
>leap seconds have occurred.  Sometimes on June 30th or December 31st,
>the last minute runs from 11:59:00 to 11:59:60 (sixty-one seconds) in
>order to compensate for wobbles in the earth's rotation.  These do
>not happen as regularly as leap days, so their occurrences cannot be
>computed by a a routine; you need a database.

The "Arthur Olson" time handling code, posted to "comp.sources.unix" (I
think), handles this in its latest version (it even includes a database
of leap seconds up to the present).

>(The dpANSI C standard had the field for seconds redefined to allow a
>value of 60 for exactly this reason.  I proposed the same correction
>to the committees standardizing Extended Pascal.)

Unfortunately, POSIX explicitly rules *out* doing this, so you probably
don't want to do this on UNIX.

Note that in 99 44/100% of the cases it doesn't make a bit of
difference; I have a Sun which means I don't trust it to get the time
right down to the second anyway....



More information about the Comp.lang.c mailing list