;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 , maybeDayPartitionToDateSpans
-- * operations -- * operations
, unionDayPartitions , unionDayPartitions
, dayPartitionSpans , dayPartitionStartEnd
, lookupDayPartition , lookupDayPartition
, splitSpan , splitSpan
, intervalBoundaryBefore , intervalBoundaryBefore
@ -125,8 +125,8 @@ unionDayPartitions (DayPartition (PeriodData h as)) (DayPartition (PeriodData h'
equalIntersection x y = and $ IM.intersectionWith (==) x y equalIntersection x y = and $ IM.intersectionWith (==) x y
-- | Get this DayPartition's overall start date and end date (both inclusive). -- | Get this DayPartition's overall start date and end date (both inclusive).
dayPartitionSpans :: DayPartition -> (Day, Day) dayPartitionStartEnd :: DayPartition -> (Day, Day)
dayPartitionSpans (DayPartition (PeriodData _ ds)) = dayPartitionStartEnd (DayPartition (PeriodData _ ds)) =
-- Guaranteed not to error because the IntMap is non-empty. -- Guaranteed not to error because the IntMap is non-empty.
(intToDay . fst $ IM.findMin ds, snd $ IM.findMax ds) (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) postingperiodend = postingPeriodEnd . postingDateOrDate2 (whichDate ropts)
where where
postingPeriodEnd d = fromMaybe err $ case interval_ ropts of 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 _ -> fmap (snd . lookupDayPartition d) . snd $ reportSpanBothDates j rspec
-- Should never happen, because there are only invalid dayPartitions -- Should never happen, because there are only invalid dayPartitions
-- when there are no transactions, in which case this function is never called -- 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. -- The requested span enlarged to enclose a whole number of intervals.
-- This can be the null span if there were no intervals. -- This can be the null span if there were no intervals.
enlargedreportspan = dbg3 "enlargedreportspan" $ 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) where mkSpan (s, e) = DateSpan (Just $ Exact s) (Just . Exact $ addDays 1 e)
reportStartDate :: Journal -> ReportSpec -> Maybe Day reportStartDate :: Journal -> ReportSpec -> Maybe Day