Bug in Time module
Simon Marlow
simonmar at microsoft.com
Wed Sep 26 10:32:12 EDT 2001
> I discovered a bug in the Time module. If I run the
> following code snippet:
>
> main :: IO ()
> main =
> do t0 <- getClockTime
> system "sleep 120"
> t1 <- getClockTime
> print (t1 `diffClockTimes` t0)
>
> The TimeDiff value has a tdSec field greater than 59, and a
> tdMin field of 0. I guess this is a bug.
I'm not sure it's a bug - Haskell 98 doesn't require that the TimeDiff
value returned from diffClockTimes is normalised in any way, and it
can't be done in general of course because months and years have
different numbers of days, even minutes have different numbers of
seconds if leap seconds are taken into account.
In GHC there's an extension Time.normalizeTimeDiff which does the
"obvious" normalization (but in fact it assumes all months have 30 days,
so it looks pretty bogus to me).
Cheers,
Simon
More information about the Glasgow-haskell-bugs
mailing list