journal: require dates to begin with a digit

This commit is contained in:
Simon Michael 2015-10-04 08:41:01 -10:00
parent aee8d2144b
commit a2f344f6d9

View File

@ -538,7 +538,10 @@ datep = do
-- hacky: try to ensure precise errors for invalid dates
-- XXX reported error position is not too good
-- pos <- genericSourcePos <$> getPosition
datestr <- many1 $ choice' [digit, datesepchar]
datestr <- do
c <- digit
cs <- many $ choice' [digit, datesepchar]
return $ c:cs
let sepchars = nub $ sort $ filter (`elem` datesepchars) datestr
when (length sepchars /= 1) $ fail $ "bad date, different separators used: " ++ datestr
let dateparts = wordsBy (`elem` datesepchars) datestr