on master help sign in
Updates UTCTime ToJSON instance to output full picosecond resolution
commit0c907c7d3ddbff6f3ea0fbaaa9b0c6547b83dcff authortimmy_tofu <timmytofu@users.noreply.github.com> dateMon 23 Mar 2015, 22:42 (12 years ago) parentcbf365b
1 file changed+5−2
Data/Aeson/Types/Instances.hs+5−2
Data/Aeson/Types/Instances.hs+5−2
@@ -482,7 +482,10 @@ instance ToJSON ZonedTime where
482482 | otherwise = "%z"
483483
484484formatMillis :: (FormatTime t) => t -> String
485−formatMillis t = take 3 . formatTime defaultTimeLocale "%q" $ t
485+formatMillis = take 3 . formatSubseconds
486+
487+formatSubseconds :: (FormatTime t) => t -> String
488+formatSubseconds = formatTime defaultTimeLocale "%q"
486489
487490instance FromJSON ZonedTime where
488491 parseJSON (String t) =
@@ -508,7 +511,7 @@ instance FromJSON ZonedTime where
508511instance ToJSON UTCTime where
509512 toJSON t = String $ pack $ formatTime defaultTimeLocale format t
510513 where
511− format = "%FT%T." ++ formatMillis t ++ "Z"
514+ format = "%FT%T." ++ formatSubseconds t ++ "Z"
512515 {-# INLINE toJSON #-}
513516
514517instance FromJSON UTCTime where