misc helpers
This commit is contained in:
parent
9ea1f4a98b
commit
77ca58269a
@ -50,6 +50,12 @@ getCurrentDay = do
|
|||||||
t <- getZonedTime
|
t <- getZonedTime
|
||||||
return $ localDay (zonedTimeToLocalTime t)
|
return $ localDay (zonedTimeToLocalTime t)
|
||||||
|
|
||||||
|
-- | Get the current local month number.
|
||||||
|
getCurrentMonth :: IO Int
|
||||||
|
getCurrentMonth = do
|
||||||
|
(_,m,_) <- toGregorian `fmap` getCurrentDay
|
||||||
|
return m
|
||||||
|
|
||||||
-- | Get the current local year.
|
-- | Get the current local year.
|
||||||
getCurrentYear :: IO Integer
|
getCurrentYear :: IO Integer
|
||||||
getCurrentYear = do
|
getCurrentYear = do
|
||||||
|
|||||||
@ -71,6 +71,10 @@ ledgerAccounts = drop 1 . flatten . ledgerAccountTree 9999
|
|||||||
ledgerTopAccounts :: Ledger -> [Account]
|
ledgerTopAccounts :: Ledger -> [Account]
|
||||||
ledgerTopAccounts = map root . branches . ledgerAccountTree 9999
|
ledgerTopAccounts = map root . branches . ledgerAccountTree 9999
|
||||||
|
|
||||||
|
-- | List a ledger's bottom-level (subaccount-less) accounts, in tree order
|
||||||
|
ledgerLeafAccounts :: Ledger -> [Account]
|
||||||
|
ledgerLeafAccounts = leaves . ledgerAccountTree 9999
|
||||||
|
|
||||||
-- | Accounts in ledger whose name matches the pattern, in tree order.
|
-- | Accounts in ledger whose name matches the pattern, in tree order.
|
||||||
ledgerAccountsMatching :: [String] -> Ledger -> [Account]
|
ledgerAccountsMatching :: [String] -> Ledger -> [Account]
|
||||||
ledgerAccountsMatching pats = filter (matchpats pats . aname) . accounts
|
ledgerAccountsMatching pats = filter (matchpats pats . aname) . accounts
|
||||||
|
|||||||
@ -42,6 +42,7 @@ module Hledger.Reports (
|
|||||||
AccountsReportItem,
|
AccountsReportItem,
|
||||||
accountsReport,
|
accountsReport,
|
||||||
accountsReport2,
|
accountsReport2,
|
||||||
|
isInteresting,
|
||||||
-- * Tests
|
-- * Tests
|
||||||
tests_Hledger_Reports
|
tests_Hledger_Reports
|
||||||
)
|
)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user