Bas van Dijk wrote:
> What's the recommended way for serializing (with the cereal package) an 
> UTCTime?

Serialize the Day part as an Integer using
toModifiedJulianDay/ModifiedJulianDay,
(Note that Day is not a constructor, it's just the name of
the type.)

Serialize the DiffTime as a Rational, as Ertugrul said.

> I'm now using the datetime package

Why? It just obscures the time library.

> But I will have to look at the code of datetime to see if I'm not
> losing precision.

You are losing precision. If you only care
about time to the nearest second, you can truncate
the Rational of the DiffTime (don't round, because
this may be the last second of a day) and then
use fromIntegral to deserialize.

Regards,
Yitz

_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to