smart dates: also accept yyyymmdd with no separators
This commit is contained in:
parent
91f3b7faac
commit
ebdf67a5ab
@ -229,7 +229,7 @@ Assumes any text in the parse stream has been lowercased.
|
||||
-}
|
||||
smartdate :: GenParser Char st SmartDate
|
||||
smartdate = do
|
||||
let dateparsers = [ymd, ym, md, y, d, month, mon, today', yesterday, tomorrow,
|
||||
let dateparsers = [yyyymmdd, ymd, ym, md, y, d, month, mon, today', yesterday, tomorrow,
|
||||
lastthisnextthing
|
||||
]
|
||||
(y,m,d) <- choice $ map try dateparsers
|
||||
@ -237,6 +237,15 @@ smartdate = do
|
||||
|
||||
datesepchar = oneOf "/-."
|
||||
|
||||
yyyymmdd :: GenParser Char st SmartDate
|
||||
yyyymmdd = do
|
||||
y <- count 4 digit
|
||||
m <- count 2 digit
|
||||
guard (read m <= 12)
|
||||
d <- count 2 digit
|
||||
guard (read d <= 31)
|
||||
return (y,m,d)
|
||||
|
||||
ymd :: GenParser Char st SmartDate
|
||||
ymd = do
|
||||
y <- many1 digit
|
||||
|
||||
Loading…
Reference in New Issue
Block a user