From 5493a604e372e7133c0afe5b7ccddf289f20a630 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Mon, 7 Dec 2009 23:29:19 +0000 Subject: [PATCH] parsing: fix timelog parsing --- Ledger/Parse.hs | 6 +++--- tests/timelog.test | 10 ++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 tests/timelog.test diff --git a/Ledger/Parse.hs b/Ledger/Parse.hs index 5dcf19c58..ef9ca9fe3 100644 --- a/Ledger/Parse.hs +++ b/Ledger/Parse.hs @@ -345,6 +345,7 @@ ledgerpartialdate = do ledgerdatetime :: GenParser Char LedgerFileCtx LocalTime ledgerdatetime = do day <- ledgerdate + many1 spacenonewline h <- many1 digit char ':' m <- many1 digit @@ -553,9 +554,8 @@ timelogentry = do code <- oneOf "bhioO" many1 spacenonewline datetime <- ledgerdatetime - many1 spacenonewline - comment <- liftM2 (++) getParentAccount restofline - return $ TimeLogEntry (read [code]) datetime comment + comment <- optionMaybe (many1 spacenonewline >> liftM2 (++) getParentAccount restofline) + return $ TimeLogEntry (read [code]) datetime (fromMaybe "" comment) -- misc parsing diff --git a/tests/timelog.test b/tests/timelog.test new file mode 100644 index 000000000..f2739cad1 --- /dev/null +++ b/tests/timelog.test @@ -0,0 +1,10 @@ +-f - print +<<< +i 2009/1/1 08:00:00 x +o 2009/1/1 09:00:00 + +>>> +2009/01/01 * 08:00-09:00 + x 1.0h + +>>>2