on master help sign in
Fix JSON instance for UTCTime to yield a valid ISO8601 string
4627164Lars Kuhtz
Data/Aeson/Types/Instances.hs+2−5
@@ -500,11 +500,8 @@ instance FromJSON ZonedTime where
500 parseJSON v = typeMismatch "ZonedTime" v
500 parseJSON v = typeMismatch "ZonedTime" v
501
501
502instance ToJSON UTCTime where
502instance ToJSON UTCTime where
503− toJSON t = String (pack (str ++ z : "Z"))
503+ toJSON t = String (pack (take 23 str ++ "Z"))
504− where (str,(x:y:_)) = splitAt 22 $
505− formatTime defaultTimeLocale "%FT%T.%q" t
504+ where str = formatTime defaultTimeLocale "%FT%T.%q" t
506− z | y < '5' = x
507− | otherwise = succ x
508 {-# INLINE toJSON #-}
505 {-# INLINE toJSON #-}
509
506
510instance FromJSON UTCTime where
507instance FromJSON UTCTime where