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