time since the epoch

Stefan Karrmann sk@mathematik.uni-ulm.de
Sun, 9 Feb 2003 11:21:49 +0100


Matthew Donadio (Fri, Feb 07, 2003 at 01:13:30PM -0500):
> Pretty much the whole world runs on UTC.  All of the common time
> distribution systems use UTC.  Technically, GPS doesn't, but the GPS
> signal includes the correction to UTC.  I understand the argument for
> using TAI.  Maybe internally the libray should use TAI, but default to
> giving the user UTC?

Yes, TAI should be the base to add seconds. (It's a total function!)
Two functions should connect it to UTC, e.g.:

taiutc :: UTCleaps -> TAItime -> (UTCtime, Bool {-isLeap-})
utctai :: UTCleaps -> Bool {- isLeap -} -> UTCtime -> TAItime

where

newtype UTCleaps = UTCleaps ( [ (TAItime,Bool {- Skipped or Additional -}) ],
                              TAItime {- valid (at least) until -} )
newtype UTCtime = UTCtime Rational

Note: o It is easy to use (utctai leaps False) and
        (\t -> first (taiutc leaps t)) as a simple interface.
      o Only, programs that run several month have to update the
        leap-seconds table more than once.

On UTCtime we can build ISO, Gregorian, Julian, etc. calendars.


Cheers,
-- 
Stefan Karrmann