Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions text-iso8601/src/Data/Time/FromText.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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@.
Expand Down
8 changes: 8 additions & 0 deletions text-iso8601/tests/text-iso8601-tests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
]
]

Expand Down
Loading