RE: Time library discussion (reprise)

I've now implemented this proposal, modulo the calendar calculations. The implementation is here: http://www.haskell.org/~simonmar/time/NewTime.hsc Compile like so with GHC 6.0.1: $ hsc2hs NewTime.hsc $ ghc -c NewTime.hs The code borrows heavily from the existing System.Time imlementation. Haddock docs here: http://www.haskell.org/~simonmar/time/NewTime.html It's quite possible I've screwed up the implementation somewhere, so please take a look. Examples: *NewTime> t <- getClockTime *NewTime> print t 1068731162437251000000 *NewTime> clockTimeToCalendarTime t >>= print Thu Nov 13 13:45:50 GMT 2003 *NewTime> clockTimeToUTCTime t Thu Nov 13 13:45:50 UTC 2003 *NewTime> clockTimeToTAITime t Thu Nov 13 13:46:02 TAI 2003 see what happens around a leap second: *NewTime> let t = CalendarTime {ctYear=1998, ctMonth=11, ctDay=31, ctHour=23, ctMin=59, ctSec=59, ctPicosec=0, ctTZ=utcTimezone} *NewTime> t Thu Dec 31 23:59:59 UTC 1998 *NewTime> clockTimeToUTCTime (fromJust (calendarTimeToClockTime t)) Thu Dec 31 23:59:59 UTC 1998 forward one second: *NewTime> clockTimeToUTCTime (fromJust (calendarTimeToClockTime t) + 1 * 10^12) Thu Dec 31 23:59:59 UTC 1998 forward 2 seconds: *NewTime> clockTimeToUTCTime (fromJust (calendarTimeToClockTime t) + 2 * 10^12) Fri Jan 1 00:00:00 UTC 1999 Cheers, Simon
participants (1)
-
Simon Marlow