Fix bug in parsing of TimeLogs, and enabled a test case for them
This commit is contained in:
parent
10263ac6d9
commit
60b4610c2f
@ -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
|
||||
|
||||
|
||||
4
Tests.hs
4
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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user