Seconds from 19xx to Date (and visa versa)

Guido van Rossum guido at cwi.nl
Fri Oct 28 21:46:01 AEST 1988


Hmm.  Leap seconds.  My quartz watch doesn't understand them, and I can
live with this.  Every so often I resynchronize with a more accurate
source of time.  Since the prime reason for time calculations in
operating systems is to use them for time stamps of files, not for
calculating durations in the order of years accurately to the second, I
propose that we define the time kept by Unix as follows:

	time = (
		(number of whole years since the epoch) * 365
		+
		(number of leap days since the epoch)
	       )
	       *
	       24*3600
	      +
	       (number of seconds since 00:00 this morning).

This makes for easy, compact conversion between time stamp values and
more conventional ways of displaying time.  On the night of a leap
second, we have an ambiguity lasting one second. Big deal.

--
Guido van Rossum, Centre for Mathematics and Computer Science (CWI), Amsterdam
guido at piring.cwi.nl or mcvax!piring!guido or guido%piring.cwi.nl at uunet.uu.net



More information about the Comp.lang.c mailing list