@@ -625,33 +625,33 @@ instance FromJSON DotNetTime where
625625 {-# INLINE parseJSON #-}
626626
627627instance ToJSON ZonedTime where
628− toJSON t = String $ pack $ formatTime defaultTimeLocale format t
629− where
630− format = "%FT%T" ++ milliseconds ++ tzFormat
631− milliseconds = take 4 $ formatTime defaultTimeLocale "%Q" t
632− tzFormat
633− | 0 == timeZoneMinutes (zonedTimeZone t) = "Z"
634− | otherwise = "%z"
628+ toJSON t = String $ pack $ formatTime defaultTimeLocale format t
629+ where
630+ format = "%FT%T" ++ milliseconds ++ tzFormat
631+ milliseconds = take 4 $ formatTime defaultTimeLocale "%Q" t
632+ tzFormat
633+ | 0 == timeZoneMinutes (zonedTimeZone t) = "Z"
634+ | otherwise = "%z"
635635
636636instance FromJSON ZonedTime where
637− parseJSON (String t) =
638− tryFormats alternateFormats
639− <|> fail "could not parse ECMA-262 ISO-8601 date"
640− where
641− tryFormat f =
642− case parseTime defaultTimeLocale f (unpack t) of
643− Just d -> pure d
644− Nothing -> empty
645− tryFormats = foldr1 (<|>) . map tryFormat
646− alternateFormats =
647− distributeList ["%Y", "%Y-%m", "%F"]
648− ["T%R", "T%T", "T%T%Q", "T%T%QZ", "T%T%Q%z"]
649−
650− distributeList xs ys =
651− foldr (\x acc -> acc ++ distribute x ys) [] xs
652− distribute x = map (mappend x)
653−
654− parseJSON v = typeMismatch "ZonedTime" v
637+ parseJSON (String t) =
638+ tryFormats alternateFormats
639+ <|> fail "could not parse ECMA-262 ISO-8601 date"
640+ where
641+ tryFormat f =
642+ case parseTime defaultTimeLocale f (unpack t) of
643+ Just d -> pure d
644+ Nothing -> empty
645+ tryFormats = foldr1 (<|>) . map tryFormat
646+ alternateFormats =
647+ distributeList ["%Y", "%Y-%m", "%F"]
648+ ["T%R", "T%T", "T%T%Q", "T%T%QZ", "T%T%Q%z"]
649+
650+ distributeList xs ys =
651+ foldr (\x acc -> acc ++ distribute x ys) [] xs
652+ distribute x = map (mappend x)
653+
654+ parseJSON v = typeMismatch "ZonedTime" v
655655
656656instance ToJSON UTCTime where
657657 toJSON t = String (pack (take 23 str ++ "Z"))