I can't get aeson to parse an UTCTime value. I tried to encode one and feed it back, but that didn't work:
Prelude Data.Aeson Data.Time.Clock> getCurrentTime >>= (print . encode)
"\"2013-10-17T09:42:49.007Z\""
Prelude Data.Aeson Data.Time.Clock> decode "2013-10-17T09:42:49.007Z" :: Maybe UTCTime
Nothing
Prelude Data.Aeson Data.Time.Clock> decode "\"2013-10-17T09:42:49.007Z\"" :: Maybe UTCTime
Nothing
The FromJSON instance of the UTCTime type is the following (ref):
instance FromJSON UTCTime where
parseJSON = withText "UTCTime" $ \t ->
case parseTime defaultTimeLocale "%FT%T%QZ" (unpack t) of
Just d -> pure d
_ -> fail "could not parse ISO-8601 date"
following the format description found here, everything should be ok. What am I missing?