From fdc13f6f438a7e808a713d21e0d0b5d11e213bbc Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Fri, 23 Jan 2009 02:27:56 +0000 Subject: [PATCH] smart dates: make "this" optional --- Ledger/Dates.hs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Ledger/Dates.hs b/Ledger/Dates.hs index 6d7910c4b..ea403073a 100644 --- a/Ledger/Dates.hs +++ b/Ledger/Dates.hs @@ -236,7 +236,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 + lastthisnextthing, thing ] (y,m,d) <- choice $ map try dateparsers return $ (y,m,d) @@ -339,6 +339,17 @@ lastthisnextthing = do return ("",r,p) +thing :: GenParser Char st SmartDate +thing = do + p <- choice $ [ + string "day" + ,string "week" + ,string "month" + ,string "quarter" + ,string "year" + ] + return ("","this",p) + periodexpr :: Day -> GenParser Char st (Interval, DateSpan) periodexpr rdate = choice $ map try [ intervalanddateperiodexpr rdate,