Permalink
Browse files

toJSON for ZonedTime limits the milliseconds to three digits

  • Loading branch information...
1 parent 4fbd5b9 commit 6d16f551549a667fef618b2dde94d0bc088d5ca8 @mike-burns mike-burns committed Jan 23, 2012
Showing with 6 additions and 6 deletions.
  1. +6 −6 Data/Aeson/Types/Class.hs
View
@@ -616,13 +616,13 @@ instance FromJSON DotNetTime where
deriving instance Eq ZonedTime
instance ToJSON ZonedTime where
- toJSON t = String $ pack $ formattedTime
+ toJSON t = String $ pack $ formatTime defaultTimeLocale format t
where
- formattedTime
- | 0 == timeZoneMinutes (zonedTimeZone t) =
- formatTime defaultTimeLocale "%FT%T%QZ" t
- | otherwise =
- formatTime defaultTimeLocale "%FT%T%Q%z" t
+ format = "%FT%T" ++ milliseconds ++ tzFormat
+ milliseconds = take 4 $ formatTime defaultTimeLocale "%Q" t
+ tzFormat
+ | 0 == timeZoneMinutes (zonedTimeZone t) = "Z"
+ | otherwise = "%z"
instance FromJSON ZonedTime where
parseJSON (String t) =

0 comments on commit 6d16f55

Please sign in to comment.