;dev: dayPartitionSpans -> dayPartitionStartEnd

This commit is contained in:
Simon Michael 2025-10-09 17:11:44 -10:00
parent 8779f2481a
commit 2e78a53931
2 changed files with 5 additions and 5 deletions

View File

@ -14,7 +14,7 @@ module Hledger.Data.DayPartition
, maybeDayPartitionToDateSpans
-- * operations
, unionDayPartitions
, dayPartitionSpans
, dayPartitionStartEnd
, lookupDayPartition
, splitSpan
, intervalBoundaryBefore
@ -125,8 +125,8 @@ unionDayPartitions (DayPartition (PeriodData h as)) (DayPartition (PeriodData h'
equalIntersection x y = and $ IM.intersectionWith (==) x y
-- | Get this DayPartition's overall start date and end date (both inclusive).
dayPartitionSpans :: DayPartition -> (Day, Day)
dayPartitionSpans (DayPartition (PeriodData _ ds)) =
dayPartitionStartEnd :: DayPartition -> (Day, Day)
dayPartitionStartEnd (DayPartition (PeriodData _ ds)) =
-- Guaranteed not to error because the IntMap is non-empty.
(intToDay . fst $ IM.findMin ds, snd $ IM.findMax ds)

View File

@ -673,7 +673,7 @@ journalApplyValuationFromOptsWith rspec@ReportSpec{_rsReportOpts=ropts} j priceo
postingperiodend = postingPeriodEnd . postingDateOrDate2 (whichDate ropts)
where
postingPeriodEnd d = fromMaybe err $ case interval_ ropts of
NoInterval -> fmap (snd . dayPartitionSpans) . snd $ reportSpan j rspec
NoInterval -> fmap (snd . dayPartitionStartEnd) . snd $ reportSpan j rspec
_ -> fmap (snd . lookupDayPartition d) . snd $ reportSpanBothDates j rspec
-- Should never happen, because there are only invalid dayPartitions
-- when there are no transactions, in which case this function is never called
@ -824,7 +824,7 @@ reportSpanHelper bothdates j ReportSpec{_rsQuery=query, _rsReportOpts=ropts, _rs
-- The requested span enlarged to enclose a whole number of intervals.
-- This can be the null span if there were no intervals.
enlargedreportspan = dbg3 "enlargedreportspan" $
maybe (DateSpan Nothing Nothing) (mkSpan . dayPartitionSpans) intervalspans
maybe (DateSpan Nothing Nothing) (mkSpan . dayPartitionStartEnd) intervalspans
where mkSpan (s, e) = DateSpan (Just $ Exact s) (Just . Exact $ addDays 1 e)
reportStartDate :: Journal -> ReportSpec -> Maybe Day