on master help sign in
Data.Aeson.Types.Instances: fix UTCTime for years outside of [0, 9999]
a6e8a3aLiyang HU
Data/Aeson/Types/Instances.hs+3−2
@@ -493,8 +493,9 @@ instance FromJSON ZonedTime where
493 parseJSON v = typeMismatch "ZonedTime" v
493 parseJSON v = typeMismatch "ZonedTime" v
494
494
495instance ToJSON UTCTime where
495instance ToJSON UTCTime where
496− toJSON t = String (pack (take 23 str ++ "Z"))
497− where str = formatTime defaultTimeLocale "%FT%T.%q" t
496+ toJSON t = String $ pack $ formatTime defaultTimeLocale format t
497+ where
498+ format = "%FT%T." ++ formatMillis t ++ "Z"
498 {-# INLINE toJSON #-}
499 {-# INLINE toJSON #-}
499
500
500instance FromJSON UTCTime where
501instance FromJSON UTCTime where