[Haskell-cafe] Serializing UTCTimes

Bas van Dijk v.dijk.bas at gmail.com
Fri Jan 20 15:03:02 CET 2012


What's the recommended way for serializing (with the cereal package) an UTCTime?

It's easy to give Serialize instances for UTCTime and Day:

instance Serialize UTCTime where
    get = liftM2 UTCTime get get
    put (UTCTime day time) = put day >> put time

instance Serialize Day where
    get = liftM Day get
    put = put . toModifiedJulianDay

However I have no idea how to serialize the DiffTime stored in an UTCTime:

instance Serialize DiffTime where
    get = ?
    put = ?



More information about the Haskell-Cafe mailing list