NorfairKing / autodocodec

self(auto)- documenting encoders and decoders

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

UTCTime codec

dustin opened this issue · comments

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

I immediately found one in the code that wasn't showing up in the docs. :/

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.

I immediately found one in the code that wasn't showing up in the docs. :/

Are you using the latest version?

Nope. I'm looking at an older snapshot. Trying with a later one.