on master help sign in
Fix JSON instance for UTCTime to yield a valid ISO8601 string

The value truncated to milliseconds by rounding down

commit462716421eb1434dbd275d7f4b30cdd0e105f46d authorLars Kuhtz <lars@alephcloud.com> dateSun 5 Jan 2014, 20:00 (13 years ago) parentcf8f509
1 file changed+2−5
Data/Aeson/Types/Instances.hs+2−5
Data/Aeson/Types/Instances.hs+2−5
@@ -500,11 +500,8 @@ instance FromJSON ZonedTime where
500500 parseJSON v = typeMismatch "ZonedTime" v
501501
502502instance ToJSON UTCTime where
503− toJSON t = String (pack (str ++ z : "Z"))
504− where (str,(x:y:_)) = splitAt 22 $
505− formatTime defaultTimeLocale "%FT%T.%q" t
506− z | y < '5' = x
507− | otherwise = succ x
503+ toJSON t = String (pack (take 23 str ++ "Z"))
504+ where str = formatTime defaultTimeLocale "%FT%T.%q" t
508505 {-# INLINE toJSON #-}
509506
510507instance FromJSON UTCTime where