diff --git a/text-iso8601/src/Data/Time/FromText.hs b/text-iso8601/src/Data/Time/FromText.hs index c51897d9e..4b1c4b8cb 100644 --- a/text-iso8601/src/Data/Time/FromText.hs +++ b/text-iso8601/src/Data/Time/FromText.hs @@ -415,6 +415,8 @@ makeTimeOfDay :: Int -> Int -> Pico -> (Local.TimeOfDay -> Either String r) -> E makeTimeOfDay h m s kont = if h < 24 && m < 60 && s < 61 then inline kont (Local.TimeOfDay h m s) + else if h == 24 && m == 0 && s == 0 + then inline kont (Local.TimeOfDay 24 0 0) else Left $ "Invalid time of day:" ++ show (h,m,s) -- Parse seconds: @SS.SSS@. diff --git a/text-iso8601/tests/text-iso8601-tests.hs b/text-iso8601/tests/text-iso8601-tests.hs index 893d4df76..622827358 100644 --- a/text-iso8601/tests/text-iso8601-tests.hs +++ b/text-iso8601/tests/text-iso8601-tests.hs @@ -61,6 +61,9 @@ main = defaultMain $ testGroup "text-iso8601" -- accepts +23:59 , accepts T.parseUTCTime "1937-01-01T12:00:00+23:59" , accepts T.parseUTCTime "1937-01-01T12:00:00-23:59" + + -- accepts 24:00:00 + , accepts T.parseUTCTime "1990-12-31T24:00:00Z" ] , testGroup "rejected" @@ -78,6 +81,11 @@ main = defaultMain $ testGroup "text-iso8601" -- accepts +23:59, but not 24 or 60 , rejects T.parseUTCTime "1937-01-01T12:00:00+24:59" , rejects T.parseUTCTime "1937-01-01T12:00:00-23:60" + + -- rejects 24:xx:xx except 24:00:00 + , rejects T.parseUTCTime "1990-12-31T24:00:01Z" + , rejects T.parseUTCTime "1990-12-31T24:00:60Z" + , rejects T.parseUTCTime "1990-12-31T24:01:00Z" ] ]