Hi, a while ago time calculation was subject on this list. Now, I have a time library based on the TAI (international atomic time) time scale.
Peter Thiemann (Thu, Feb 06, 2003 at 12:40:14PM -0800):
John's code illustrates TimeDiff's deficiencies perfectly:
There is also a more fundamental problem with the TimeDiff data type. While seconds, minutes, hours, and days are clearly specified amounts of time, the duration of a month or a year may vary depending on the reference point where the time difference is applied.
newtype TimeDiff = TimeDiff Rational deriving (Eq, Ord)
Hmm, this is underspecified! As another poster said, (pointing out http://cr.yp.to/libtai, but it is better to look at http://cr.yp.to/time.html, which has a discussion on UTC vs TAI vs UNIX time) the official source of time is TAI, so it is best to base a time library *on the number of TAI seconds since a reference date* (which is btw what the libtai is all about). For compatibility with UNIX time, "Arthur David Olson's popular time library uses an epoch of 1970-01-01 00:00:10 TAI" [http://cr.yp.to/proto/utctai.html]. So this mostly means that you need to set your system clock correctly:-)
Sincerly, -- Stefan Karrmann