[Haskell-cafe] Re: Strange breakage after Hugs upgrade [FIXED]

John Goerzen jgoerzen at complete.org
Tue Apr 5 14:43:42 EDT 2005


On 2005-04-05, John Goerzen <jgoerzen at complete.org> wrote:
> On 2005-04-05, John Goerzen <jgoerzen at complete.org> wrote:
> Anyway, the question remains: what is a portable way of converting an
> EpochTime to a TOD x y value, that works on Hugs 2003, Hugs 2005, GHC
> 6.2, and GHC 6.4?

And to follow up to myself yet again, I just checked this into MissingH
(feel free to steal for fptools):

{- | Converts an Epoch time represented with an arbitrary Real to a ClockTime.
This input could be a CTime from Foreign.C.Types or an EpochTime from
System.Posix.Types. -}
epochToClockTime :: Real a => a -> ClockTime
epochToClockTime x =
    TOD seconds secfrac
    where ratval = toRational x
          seconds = floor ratval
          secfrac = floor $ (ratval - (seconds % 1) ) * picosecondfactor
          picosecondfactor = 10 ^ 12

-- John




More information about the Haskell-Cafe mailing list