From 60b4610c2fca667f1bb0cbbe07314843e016dd4a Mon Sep 17 00:00:00 2001 From: tim Date: Wed, 12 Nov 2008 07:17:31 +0000 Subject: [PATCH] Fix bug in parsing of TimeLogs, and enabled a test case for them --- Ledger/Parse.hs | 10 ++++++---- Tests.hs | 4 +++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Ledger/Parse.hs b/Ledger/Parse.hs index 75f030967..fb9a29ced 100644 --- a/Ledger/Parse.hs +++ b/Ledger/Parse.hs @@ -242,7 +242,7 @@ ledgerday = do m <- many1 digit char '/' d <- many1 digit - many1 spacenonewline + many spacenonewline return (fromGregorian (read y) (read m) (read d)) ledgerdate :: Parser Date @@ -254,8 +254,11 @@ ledgerdatetime = do h <- many1 digit char ':' m <- many1 digit - many1 spacenonewline - return (mkDateTime day (TimeOfDay (read h) (read m) 0)) + s <- optionMaybe $ do + char ':' + many1 digit + many spacenonewline + return (mkDateTime day (TimeOfDay (read h) (read m) (maybe 0 (fromIntegral.read) s))) ledgerstatus :: Parser Bool @@ -468,7 +471,6 @@ timelogentry = do code <- oneOf "bhioO" many1 spacenonewline datetime <- ledgerdatetime - many spacenonewline comment <- restofline return $ TimeLogEntry code datetime comment diff --git a/Tests.hs b/Tests.hs index 797118cf7..a3f98bbe9 100644 --- a/Tests.hs +++ b/Tests.hs @@ -89,7 +89,9 @@ misc_tests = TestList [ "canonicaliseAmounts" ~: do -- all amounts use the greatest precision assertequal [2,2] (rawLedgerPrecisions $ canonicaliseAmounts $ rawLedgerWithAmounts ["1","2.00"]) - + , + "timeLog" ~: do + assertparseequal timelog1 (parsewith timelog timelog1_str) ] balancereportacctnames_tests = TestList