Time Libraries Rough Draft

Scott Turner p.turner at computer.org
Wed Feb 9 20:59:59 EST 2005

Ashley Yakeley wrote:
>   data UTCTime = MkUTCTime JulianDay DiffTime
>   newtype UTCDiffTime = MkUTCDiffTime Integer
>   utcTimeToUTCSeconds :: UTCDiffTime -> Rational
>   utcSecondsToUTCTime :: Rational -> UTCDiffTime
>   addUTCTime :: UTCDiffTime -> UTCTime -> UTCTime
>   diffUTCTime :: UTCTime -> UTCTime -> UTCDiffTime

A good draft.  Questions:
1. Are DiffTime and UTCDiffTime specified as picoseconds, or must we use 
timeToSISeconds when we need a time difference with units?
2. In a UTCTime, is the DiffTime limited to 86400 or 86401 or unlimited?

I don't see an overall benefit from distinguishing UTCDiffTime from DiffTime.  
The representation of UTCTime forces them to have identical precision and 
often to have the same meaning.

The names timeToSISeconds and siSecondsToTime might be better without the SI, 
as timeToSeconds and secondsToTime. Our clocks will be having hiccups when 
leap seconds arrive so they won't always tell SI seconds. Also times prior to 
UTC have seconds of different lengths.

The addUTCTime and diffUTCTime functions are a concern because your earlier 
email said that they should ignore leap seconds.  That is plenty useful but 
it's likely to bite a naive user.  I'd like them to be called 
addUTCTimeNoLeap and diffUTCTimeNoLeap.

More information about the Libraries mailing list