misc helpers

This commit is contained in:
Simon Michael 2011-08-07 15:31:36 +00:00
parent 9ea1f4a98b
commit 77ca58269a
3 changed files with 11 additions and 0 deletions

View File

@ -50,6 +50,12 @@ getCurrentDay = do
t <- getZonedTime
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.
getCurrentYear :: IO Integer
getCurrentYear = do

View File

@ -71,6 +71,10 @@ ledgerAccounts = drop 1 . flatten . ledgerAccountTree 9999
ledgerTopAccounts :: Ledger -> [Account]
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.
ledgerAccountsMatching :: [String] -> Ledger -> [Account]
ledgerAccountsMatching pats = filter (matchpats pats . aname) . accounts

View File

@ -42,6 +42,7 @@ module Hledger.Reports (
AccountsReportItem,
accountsReport,
accountsReport2,
isInteresting,
-- * Tests
tests_Hledger_Reports
)