Skip to content

Commit afd3673

Browse files
authored
Merge pull request #618 from gbaz/patch-1
Improve error message on day parse fail
2 parents a4e4cab + 556c1f1 commit afd3673

File tree

1 file changed

+3
-3
lines changed
  • attoparsec-iso8601/Data/Attoparsec

1 file changed

+3
-3
lines changed

attoparsec-iso8601/Data/Attoparsec/Time.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ import qualified Data.Time.LocalTime as Local
4242
day :: Parser Day
4343
day = do
4444
absOrNeg <- negate <$ char '-' <|> id <$ char '+' <|> pure id
45-
y <- decimal <* char '-'
46-
m <- twoDigits <* char '-'
47-
d <- twoDigits
45+
y <- (decimal <* char '-') <|> fail "date must be of form [+,-]YYYY-MM-DD"
46+
m <- (twoDigits <* char '-') <|> fail "date must be of form [+,-]YYYY-MM-DD"
47+
d <- twoDigits <|> fail "date must be of form [+,-]YYYY-MM-DD"
4848
maybe (fail "invalid date") return (fromGregorianValid (absOrNeg y) m d)
4949

5050
-- | Parse a two-digit integer (e.g. day of month, hour).

0 commit comments

Comments
 (0)