on master help sign in
toJSON for ZonedTime limits the milliseconds to three digits
commite8f5b3f8453abb6d34ad9c27b1be90b2680a5b70 authorMike Burns <mike@mike-burns.com> dateSun 22 Jan 2012, 20:31 (15 years ago) parent8fec44b
1 file changed+6−6
Data/Aeson/Types/Class.hs+6−6
Data/Aeson/Types/Class.hs+6−6
@@ -616,13 +616,13 @@ instance FromJSON DotNetTime where
616616deriving instance Eq ZonedTime
617617
618618instance ToJSON ZonedTime where
619− toJSON t = String $ pack $ formattedTime
619+ toJSON t = String $ pack $ formatTime defaultTimeLocale format t
620620 where
621− formattedTime
622− | 0 == timeZoneMinutes (zonedTimeZone t) =
623− formatTime defaultTimeLocale "%FT%T%QZ" t
624− | otherwise =
625− formatTime defaultTimeLocale "%FT%T%Q%z" t
621+ format = "%FT%T" ++ milliseconds ++ tzFormat
622+ milliseconds = take 4 $ formatTime defaultTimeLocale "%Q" t
623+ tzFormat
624+ | 0 == timeZoneMinutes (zonedTimeZone t) = "Z"
625+ | otherwise = "%z"
626626
627627instance FromJSON ZonedTime where
628628 parseJSON (String t) =