On 2005-04-05, John Goerzen <[EMAIL PROTECTED]> wrote:
> On 2005-04-05, John Goerzen <[EMAIL PROTECTED]> 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
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe