From 9ac1d7869bf1f754f5303a76e6dc945dc157b8f7 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Tue, 23 Apr 2019 13:58:32 -0700 Subject: [PATCH] lib: journalStartDate, journalEndDate --- hledger-lib/Hledger/Data/Journal.hs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/hledger-lib/Hledger/Data/Journal.hs b/hledger-lib/Hledger/Data/Journal.hs index 9772e2547..963b67396 100644 --- a/hledger-lib/Hledger/Data/Journal.hs +++ b/hledger-lib/Hledger/Data/Journal.hs @@ -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