refactor: cleanup
This commit is contained in:
parent
b19b02962a
commit
331ed6b407
@ -590,7 +590,7 @@ tests = TestList [
|
||||
["2009/01/01 медвежья шкура расходы:покупки 100 100"
|
||||
," актив:наличные -100 0"]
|
||||
|
||||
,"smart dates" ~: do
|
||||
,"fixSmartDateStr" ~: do
|
||||
let gives = is . fixSmartDateStr (parsedate "2008/11/26")
|
||||
"1999-12-02" `gives` "1999/12/02"
|
||||
"1999.12.02" `gives` "1999/12/02"
|
||||
|
||||
@ -246,10 +246,7 @@ Assumes any text in the parse stream has been lowercased.
|
||||
-}
|
||||
smartdate :: GenParser Char st SmartDate
|
||||
smartdate = do
|
||||
let dateparsers = [yyyymmdd, ymd, ym, md, y, d, month, mon, today, yesterday, tomorrow,
|
||||
lastthisnextthing
|
||||
]
|
||||
(y,m,d) <- choice $ map try dateparsers
|
||||
(y,m,d) <- choice' [yyyymmdd, ymd, ym, md, y, d, month, mon, today, yesterday, tomorrow, lastthisnextthing]
|
||||
return (y,m,d)
|
||||
|
||||
-- | Like smartdate, but there must be nothing other than whitespace after the date.
|
||||
|
||||
@ -241,6 +241,8 @@ tracewith f e = trace (f e) e
|
||||
|
||||
-- parsing
|
||||
|
||||
choice' = choice . map Text.ParserCombinators.Parsec.try
|
||||
|
||||
parsewith :: Parser a -> String -> Either ParseError a
|
||||
parsewith p = parse p ""
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user