A Bug in Time?

Dominic Steinitz dominic.steinitz@blueyonder.co.uk
Thu, 30 May 2002 11:35:40 +0100


Hugs has a bug in Time. I would expect toUTCTime and toCalendarTime to be
inverses of toClockTime (modulo the IO monad).

toCalendarTime       :: ClockTime    -> IO CalendarTime
toUTCTime            :: ClockTime    -> CalendarTime
toClockTime          :: CalendarTime -> ClockTime

module Main(main) where

import Time

main = putStrLn "Hello"

test :: Integer -> IO ()
test x = (toCalendarTime . toClockTime .  f $ x) >>= putStrLn . show

f x = CalendarTime{ctYear=2002,
                 ctMonth=May,
                 ctDay=30,
                 ctHour=10,
                 ctMin=27,
                 ctSec=11,
                 ctPicosec=x,
                 ctWDay=Thursday,
                 ctYDay=149,
                 ctTZName="BST",
                 ctTZ=3600,
                 ctIsDST=True}

GHC gives:

Main> test 1
CalendarTime{ctYear=2002,ctMonth=May,ctDay=30,ctHour=10,ctMin=27,ctSec=11,ct
Picose
c=1,ctWDay=Thursday,ctYDay=149,ctTZName="BST",ctTZ=3600,ctIsDST=True}
Main> test 2
CalendarTime{ctYear=2002,ctMonth=May,ctDay=30,ctHour=10,ctMin=27,ctSec=11,ct
Picose
c=2,ctWDay=Thursday,ctYDay=149,ctTZName="BST",ctTZ=3600,ctIsDST=True}

Hugs gives

Main> test 1
CalendarTime{ctYear=2002,ctMonth=May,ctDay=30,ctHour=10,ctMin=27,ctSec=11,ct
Picose
c=0,ctWDay=Thursday,ctYDay=149,ctTZName="BST",ctTZ=3600,ctIsDST=True}

Main> test 2
CalendarTime{ctYear=2002,ctMonth=May,ctDay=30,ctHour=10,ctMin=27,ctSec=11,ct
Picose
c=0,ctWDay=Thursday,ctYDay=149,ctTZName="BST",ctTZ=3600,ctIsDST=True}

Dominic Steinitz