diff --git a/hledger-lib/Hledger/Data/Journal.hs b/hledger-lib/Hledger/Data/Journal.hs index d2e6aacf1..37fc1b3e9 100644 --- a/hledger-lib/Hledger/Data/Journal.hs +++ b/hledger-lib/Hledger/Data/Journal.hs @@ -60,6 +60,7 @@ module Hledger.Data.Journal ( journalDateSpanBothDates, journalStartDate, journalEndDate, + journalLastDay, journalDescriptions, journalFilePath, journalFilePaths, @@ -1316,11 +1317,16 @@ journalDateSpanHelper whichdate j = 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. +-- | The "exclusive end date" of this journal: the day following its latest transaction +-- or posting date, or Nothing if there are none. journalEndDate :: Bool -> Journal -> Maybe Day journalEndDate secondary j = e where DateSpan _ e = journalDateSpan secondary j +-- | The latest of this journal's transaction and posting dates, or +-- Nothing if there are none. +journalLastDay :: Bool -> Journal -> Maybe Day +journalLastDay secondary j = addDays (-1) <$> journalEndDate 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