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
|
m <- many1 digit
|
||||||
char '/'
|
char '/'
|
||||||
d <- many1 digit
|
d <- many1 digit
|
||||||
many1 spacenonewline
|
many spacenonewline
|
||||||
return (fromGregorian (read y) (read m) (read d))
|
return (fromGregorian (read y) (read m) (read d))
|
||||||
|
|
||||||
ledgerdate :: Parser Date
|
ledgerdate :: Parser Date
|
||||||
@ -254,8 +254,11 @@ ledgerdatetime = do
|
|||||||
h <- many1 digit
|
h <- many1 digit
|
||||||
char ':'
|
char ':'
|
||||||
m <- many1 digit
|
m <- many1 digit
|
||||||
many1 spacenonewline
|
s <- optionMaybe $ do
|
||||||
return (mkDateTime day (TimeOfDay (read h) (read m) 0))
|
char ':'
|
||||||
|
many1 digit
|
||||||
|
many spacenonewline
|
||||||
|
return (mkDateTime day (TimeOfDay (read h) (read m) (maybe 0 (fromIntegral.read) s)))
|
||||||
|
|
||||||
|
|
||||||
ledgerstatus :: Parser Bool
|
ledgerstatus :: Parser Bool
|
||||||
@ -468,7 +471,6 @@ timelogentry = do
|
|||||||
code <- oneOf "bhioO"
|
code <- oneOf "bhioO"
|
||||||
many1 spacenonewline
|
many1 spacenonewline
|
||||||
datetime <- ledgerdatetime
|
datetime <- ledgerdatetime
|
||||||
many spacenonewline
|
|
||||||
comment <- restofline
|
comment <- restofline
|
||||||
return $ TimeLogEntry code datetime comment
|
return $ TimeLogEntry code datetime comment
|
||||||
|
|
||||||
|
|||||||
4
Tests.hs
4
Tests.hs
@ -89,7 +89,9 @@ misc_tests = TestList [
|
|||||||
"canonicaliseAmounts" ~: do
|
"canonicaliseAmounts" ~: do
|
||||||
-- all amounts use the greatest precision
|
-- all amounts use the greatest precision
|
||||||
assertequal [2,2] (rawLedgerPrecisions $ canonicaliseAmounts $ rawLedgerWithAmounts ["1","2.00"])
|
assertequal [2,2] (rawLedgerPrecisions $ canonicaliseAmounts $ rawLedgerWithAmounts ["1","2.00"])
|
||||||
|
,
|
||||||
|
"timeLog" ~: do
|
||||||
|
assertparseequal timelog1 (parsewith timelog timelog1_str)
|
||||||
]
|
]
|
||||||
|
|
||||||
balancereportacctnames_tests = TestList
|
balancereportacctnames_tests = TestList
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user