[Haskell-cafe] Re: Can't do basic time operations with System.Time
simonmar at microsoft.com
Tue Jan 25 10:15:38 EST 2005
On 21 January 2005 21:50, John Goerzen wrote:
> On 2005-01-21, Peter Simons <simons at cryp.to> wrote:
>>> 24 * ((fromIntegral $ tdDay td) +
>>> 30 * ((fromIntegral $ tdMonth td) +
>>> 365 * (fromIntegral $ tdYear td)))))
>> I was wondering: Does this calculation account for leap
>> years? Does it have to?
> I also wondered about all months being 30 days. But this exact
> algorithm is used in fptools' normalizeTimeDiff, and it seems to work
> out correctly, so I guess the timeDiff functions assume that every
> month has 30 days and every year has 365.
normalizeTimeDiff (and TimeDiff in general) is wrong. I wouldn't
recommend using it. There's the TimeExts library in the lang package,
which might be useful to you.
More information about the Haskell-Cafe