the haskell 98 time library is horribly broken, if you are using ghc, you can deconstruct the time constructor which has an Integer containing the number of seconds since epoch... otherwise you can use
epoch :: ClockTime epoch = toClockTime $ CalendarTime { ctYear = 1970, ctMonth = January, ctDay = 0, ctHour = 0, ctMin = 0, ctSec = 0, ctTZ = 0, ctPicosec = 0, ctWDay = undefined, ctYDay = undefined, ctTZName = undefined, ctIsDST = undefined} and TimeDiff, unfortunatly you have to condense the TimeDiff to seconds, which is unfeasable... we really should fix the Haskell time library. I propose adding: toRawTime :: ClockTime -> (Integer,Integer) fromRawTime :: (Integer,Integer) -> ClockTime where the integers are the number of seconds and picoseconds since epoch, these would be enough to make the time library useful. I dont supose this could be considered a typo in the haskell 98 report? it is an embarasing thing for a language to not be able to do... John On Fri, Jan 31, 2003 at 04:20:29PM -0500, Mike T. Machenry wrote: > I am looking for a simple way to get the current days sincethe epoch. Most > language's standard time library have a get-seconds function that returns > the number of seconds since the epoch, thus the function is for example > in scheme: > > (define (days-since-epoch) > ((get-seconds) / (* 60 60 24))) > > But it seems that in haskell the standard definition for the time library > will not give me seconds since the epoch. There is technically enough > information in the CalendarTime structure to calculate it, but it is a > pretty complicated algorithm. Not to mention the fact that it is the > exact opposite of the algorithm used to get that information in the first > place, so I'd like to not have to undo it and just get the seconds as they > are. > > Thanks for the help > -mike > _______________________________________________ > Haskell mailing list > [EMAIL PROTECTED] > http://www.haskell.org/mailman/listinfo/haskell > -- --------------------------------------------------------------------------- John Meacham - California Institute of Technology, Alum. - [EMAIL PROTECTED] --------------------------------------------------------------------------- _______________________________________________ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell