
21 Jan
2012
21 Jan
'12
4:29 p.m.
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