RE: [Haskell-cafe] Re: Can't do basic time operations with System.Time

On 21 January 2005 21:50, John Goerzen wrote:
On 2005-01-21, Peter Simons
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. Cheers, Simon

On Tue, Jan 25, 2005 at 03:15:38PM -0000, Simon Marlow wrote:
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.
I'm curious about that package. It's in my ghc source tree but not documented at http://www.haskell.org/ghc/docs/latest/html/libraries/index.html. Is it assumed to be portable and available outside ghc? Thanks, John
participants (2)
-
John Goerzen
-
Simon Marlow