
On Fri, Jan 21, 2005 at 02:55:31PM -0000, Simon Marlow wrote:
Have you seen this, BTW:
Ah. I think I found several discussions in reply to that but never did actually track down that URL. I'll take a look.
timelocal :: CalendarTime -> IO Integer
This looks useful, given that it was what you wanted and it isn't already provided. I'd prefer to drop it into the existing library, and have it return a ClockTime, though. Perhaps:
I did it as it was because the standard defined ClockTime to be opaque. Obviously it's not in fptools, so your way is fine there. But the method of getting seconds out of it should be documented, or a simple function could be added: -- | Convert a ClockTime to a POSIX seconds-since-epoch representation. clockTimeToEpochTime :: ClockTime -> Integer clockTimeToEpochTime (TOD x _) = x
-- | converts the given CalendarTime into a ClockTime, -- ignoring the ctTZ field of CalendarTime and instead -- using the prevailing local timezone (including daylight -- savings adjustments) at the given time. localTimeToClockTime :: CalendarTime -> IO ClockTime
that's more or less a direct interface to mktime().
That would be fine too (you might also note that ctIsDST is ignored). -- John