From 5d2caf3c7f40f8a9e6114db42a7511a1f2aa29a8 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Sun, 11 Jul 2021 10:52:50 -1000 Subject: [PATCH] lib: clarify journalEndDate, add journalLastDay --- hledger-lib/Hledger/Data/Journal.hs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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