lib: Hledger.Data.Dates: intervalStartBefore -> intervalBoundaryBefore

This commit is contained in:
Simon Michael 2023-01-11 07:32:59 -10:00
parent 8f9c35200f
commit 93f74f7a0e
2 changed files with 4 additions and 4 deletions

View File

@ -75,7 +75,7 @@ module Hledger.Data.Dates (
daysInSpan,
tests_Dates
, intervalStartBefore)
, intervalBoundaryBefore)
where
import qualified Control.Monad.Fail as Fail (MonadFail, fail)
@ -548,8 +548,8 @@ nextyear = startofyear . addGregorianYearsClip 1
startofyear day = fromGregorian y 1 1 where (y,_,_) = toGregorian day
-- Get the natural start for the given interval that falls on or before the given day.
intervalStartBefore :: Interval -> Day -> Day
intervalStartBefore int d =
intervalBoundaryBefore :: Interval -> Day -> Day
intervalBoundaryBefore int d =
case splitSpan int (DateSpan (Just d) (Just $ addDays 1 d)) of
(DateSpan (Just start) _:_) -> start
_ -> d

View File

@ -139,7 +139,7 @@ journalAddBudgetGoalTransactions bopts ropts reportspan j =
pts -> (ptinterval pt, ptspan pt)
where pt = maximumBy (comparing ptinterval) pts -- PARTIAL: maximumBy won't fail
-- the natural start of this interval on or before the journal/report start
intervalstart = intervalStartBefore intervl d
intervalstart = intervalBoundaryBefore intervl d
-- the natural interval start before the journal/report start,
-- or the rule-specified start if later,
-- but no later than the journal/report start.