lib: journalStartDate, journalEndDate

This commit is contained in:
Simon Michael 2019-04-23 13:58:32 -07:00
parent 1cacfcea28
commit 9ac1d7869b

View File

@ -48,6 +48,8 @@ module Hledger.Data.Journal (
traverseJournalAmounts,
-- journalCanonicalCommodities,
journalDateSpan,
journalStartDate,
journalEndDate,
journalDescriptions,
journalFilePath,
journalFilePaths,
@ -1040,6 +1042,16 @@ journalDateSpan secondary j
pdates = concatMap (mapMaybe (if secondary then (Just . postingDate2) else pdate) . tpostings) ts
ts = jtxns j
-- | The earliest of this journal's transaction and posting dates, or
-- Nothing if there are none.
journalStartDate :: Bool -> Journal -> Maybe Day
journalStartDate secondary j = b where DateSpan b _ = journalDateSpan secondary j
-- | The latest of this journal's transaction and posting dates, or
-- Nothing if there are none.
journalEndDate :: Bool -> Journal -> Maybe Day
journalEndDate secondary j = e where DateSpan _ e = journalDateSpan secondary j
-- | Apply the pivot transformation to all postings in a journal,
-- replacing their account name by their value for the given field or tag.
journalPivot :: Text -> Journal -> Journal