UTCTime codec
dustin opened this issue · comments
Dustin Sallings commented
Aeson has a lot of code for transcoding UTCTime
, so I assume compatibility might be non-trivial, but something like might be a starting point:
instance HasCodec UTCTime where
codec = bimapCodec fromText toText textCodec
where
fromText t = maybe (Left $ "can't parse time: " <> show t) Right . formatParseM iso8601Format $ T.unpack t
toText = T.pack . formatShow iso8601Format -- this is theoretically partial
Dustin Sallings commented
I immediately found one in the code that wasn't showing up in the docs. :/
Tom Sydney Kerckhove commented
For backward compatibility reasons, the codec
that autodocodec
uses must encode and decode values in the same way.
That's why we use codecViaAeson
in the current version.
Tom Sydney Kerckhove commented
I immediately found one in the code that wasn't showing up in the docs. :/
Are you using the latest version?
Dustin Sallings commented
Nope. I'm looking at an older snapshot. Trying with a later one.