diff --git a/Hledger/Cli/Tests.hs b/Hledger/Cli/Tests.hs index f38cd34f8..8aa7660ce 100644 --- a/Hledger/Cli/Tests.hs +++ b/Hledger/Cli/Tests.hs @@ -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" diff --git a/hledger-lib/Hledger/Data/Dates.hs b/hledger-lib/Hledger/Data/Dates.hs index 7ed6b8bba..78b5411f5 100644 --- a/hledger-lib/Hledger/Data/Dates.hs +++ b/hledger-lib/Hledger/Data/Dates.hs @@ -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. diff --git a/hledger-lib/Hledger/Data/Utils.hs b/hledger-lib/Hledger/Data/Utils.hs index 6a8c807c4..51ceb6397 100644 --- a/hledger-lib/Hledger/Data/Utils.hs +++ b/hledger-lib/Hledger/Data/Utils.hs @@ -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 ""