fix: stats: fix a regression in date display since 1.28 (#2012)

This commit is contained in:
Simon Michael 2023-03-16 14:52:37 -10:00
parent ee29893040
commit 70ef3e816c

View File

@ -70,7 +70,7 @@ showLedgerStats l today spn =
(stts, tnum) = ([ (stts, tnum) = ([
("Main file", path) -- ++ " (from " ++ source ++ ")") ("Main file", path) -- ++ " (from " ++ source ++ ")")
,("Included files", unlines $ drop 1 $ journalFilePaths j) ,("Included files", unlines $ drop 1 $ journalFilePaths j)
,("Transactions span", printf "%s to %s (%d days)" (start spn) (end spn) days) ,("Transactions span", printf "%s to %s (%d days)" (showstart spn) (showend spn) days)
,("Last transaction", maybe "none" show lastdate ++ showelapsed lastelapsed) ,("Last transaction", maybe "none" show lastdate ++ showelapsed lastelapsed)
,("Transactions", printf "%d (%0.1f per day)" tnum txnrate) ,("Transactions", printf "%d (%0.1f per day)" tnum txnrate)
,("Transactions last 30 days", printf "%d (%0.1f per day)" tnum30 txnrate30) ,("Transactions last 30 days", printf "%d (%0.1f per day)" tnum30 txnrate30)
@ -100,10 +100,10 @@ showLedgerStats l today spn =
direction | dys >= 0 = "days ago" :: String direction | dys >= 0 = "days ago" :: String
| otherwise = "days from now" | otherwise = "days from now"
tnum1 = length ts -- Integer would be better tnum1 = length ts -- Integer would be better
start (DateSpan (Just d) _) = show d showstart (DateSpan (Just efd) _) = show $ fromEFDay efd
start _ = "" showstart _ = ""
end (DateSpan _ (Just d)) = show d showend (DateSpan _ (Just efd)) = show $ fromEFDay efd
end _ = "" showend _ = ""
days = fromMaybe 0 $ daysInSpan spn days = fromMaybe 0 $ daysInSpan spn
txnrate | days==0 = 0 txnrate | days==0 = 0
| otherwise = fromIntegral tnum1 / fromIntegral days :: Double | otherwise = fromIntegral tnum1 / fromIntegral days :: Double