module Hledger.Cli.Commands.Print
where
import Hledger.Data
import Hledger.Cli.Options
#if __GLASGOW_HASKELL__ <= 610
import Prelude hiding ( putStr )
import System.IO.UTF8
#endif
print' :: [Opt] -> [String] -> Journal -> IO ()
print' opts args j = do
t <- getCurrentLocalTime
putStr $ showTransactions (optsToFilterSpec opts args t) j
showTransactions :: FilterSpec -> Journal -> String
showTransactions filterspec j =
concatMap (showTransactionForPrint effective) $ sortBy (comparing tdate) txns
where
effective = EffectiveDate == whichdate filterspec
txns = jtxns $ filterJournalTransactions filterspec j