[Haskell-cafe] Re: TimeDiff to Int?

Jon Fairbairn jon.fairbairn at cl.cam.ac.uk
Fri Nov 14 05:06:23 EST 2008

"Lyle Kopnicky" <lists at qseep.net> writes:

> Thanks, but that doesn't seem to work. I got an answer of -3. I tried it
> again a minute later and it was still -3. I tried again a minute later and
> it was -1. It's just after 9am here, so I have no idea what to make of
> those numbers.

That's most strange. The only difference between what I
wrote and what you had before was the way the conversion to
Integer was done.

> I have settled on this code:
> secondsSinceMidnight :: IO Int
> secondsSinceMidnight = do
>   zonedTime <- getZonedTime
>   return $ floor $ toRational $ timeOfDayToTime $ localTimeOfDay $
> zonedTimeToLocalTime zonedTime

So what happens with

do now <- getZonedTime; print $ (fromEnum $ timeOfDayToTime $ localTimeOfDay $ zonedTimeToLocalTime now)`div`fromEnum (secondsToDiffTime 1)

where you are?

Jón Fairbairn                                 Jon.Fairbairn at cl.cam.ac.uk

More information about the Haskell-Cafe mailing list