ui: clarify docs of some period functions
This commit is contained in:
parent
91c524b600
commit
6aeaee17f5
@ -143,7 +143,8 @@ periodEnd p = me
|
|||||||
where
|
where
|
||||||
DateSpan _ me = periodAsDateSpan p
|
DateSpan _ me = periodAsDateSpan p
|
||||||
|
|
||||||
-- | Move a period to the following period of same duration.
|
-- | Move a standard period (day, week, month etc.) to the following period of same duration.
|
||||||
|
-- Non-standard periods are unaffected.
|
||||||
periodNext :: Period -> Period
|
periodNext :: Period -> Period
|
||||||
periodNext (DayPeriod b) = DayPeriod (addDays 1 b)
|
periodNext (DayPeriod b) = DayPeriod (addDays 1 b)
|
||||||
periodNext (WeekPeriod b) = WeekPeriod (addDays 7 b)
|
periodNext (WeekPeriod b) = WeekPeriod (addDays 7 b)
|
||||||
@ -154,7 +155,8 @@ periodNext (QuarterPeriod y q) = QuarterPeriod y (q+1)
|
|||||||
periodNext (YearPeriod y) = YearPeriod (y+1)
|
periodNext (YearPeriod y) = YearPeriod (y+1)
|
||||||
periodNext p = p
|
periodNext p = p
|
||||||
|
|
||||||
-- | Move a period to the preceding period of same duration.
|
-- | Move a standard period (day, week, month etc.) to the preceding period of same duration.
|
||||||
|
-- Non-standard periods are unaffected.
|
||||||
periodPrevious :: Period -> Period
|
periodPrevious :: Period -> Period
|
||||||
periodPrevious (DayPeriod b) = DayPeriod (addDays (-1) b)
|
periodPrevious (DayPeriod b) = DayPeriod (addDays (-1) b)
|
||||||
periodPrevious (WeekPeriod b) = WeekPeriod (addDays (-7) b)
|
periodPrevious (WeekPeriod b) = WeekPeriod (addDays (-7) b)
|
||||||
@ -165,7 +167,8 @@ periodPrevious (QuarterPeriod y q) = QuarterPeriod y (q-1)
|
|||||||
periodPrevious (YearPeriod y) = YearPeriod (y-1)
|
periodPrevious (YearPeriod y) = YearPeriod (y-1)
|
||||||
periodPrevious p = p
|
periodPrevious p = p
|
||||||
|
|
||||||
-- | Move a period to the following period of same duration, staying within enclosing dates.
|
-- | Move a standard period to the following period of same duration, staying within enclosing dates.
|
||||||
|
-- Non-standard periods are unaffected.
|
||||||
periodNextIn :: DateSpan -> Period -> Period
|
periodNextIn :: DateSpan -> Period -> Period
|
||||||
periodNextIn (DateSpan _ (Just e)) p =
|
periodNextIn (DateSpan _ (Just e)) p =
|
||||||
case mb of
|
case mb of
|
||||||
@ -176,7 +179,8 @@ periodNextIn (DateSpan _ (Just e)) p =
|
|||||||
mb = periodStart p'
|
mb = periodStart p'
|
||||||
periodNextIn _ p = periodNext p
|
periodNextIn _ p = periodNext p
|
||||||
|
|
||||||
-- | Move a period to the preceding period of same duration, staying within enclosing dates.
|
-- | Move a standard period to the preceding period of same duration, staying within enclosing dates.
|
||||||
|
-- Non-standard periods are unaffected.
|
||||||
periodPreviousIn :: DateSpan -> Period -> Period
|
periodPreviousIn :: DateSpan -> Period -> Period
|
||||||
periodPreviousIn (DateSpan (Just b) _) p =
|
periodPreviousIn (DateSpan (Just b) _) p =
|
||||||
case me of
|
case me of
|
||||||
@ -187,7 +191,8 @@ periodPreviousIn (DateSpan (Just b) _) p =
|
|||||||
me = periodEnd p'
|
me = periodEnd p'
|
||||||
periodPreviousIn _ p = periodPrevious p
|
periodPreviousIn _ p = periodPrevious p
|
||||||
|
|
||||||
-- | Move a period stepwise so that it encloses the given date.
|
-- | Move a standard period stepwise so that it encloses the given date.
|
||||||
|
-- Non-standard periods are unaffected.
|
||||||
periodMoveTo :: Day -> Period -> Period
|
periodMoveTo :: Day -> Period -> Period
|
||||||
periodMoveTo d (DayPeriod _) = DayPeriod d
|
periodMoveTo d (DayPeriod _) = DayPeriod d
|
||||||
periodMoveTo d (WeekPeriod _) = WeekPeriod $ mondayBefore d
|
periodMoveTo d (WeekPeriod _) = WeekPeriod $ mondayBefore d
|
||||||
@ -203,7 +208,7 @@ periodMoveTo _ p = p
|
|||||||
-- Eg, a day becomes the enclosing week.
|
-- Eg, a day becomes the enclosing week.
|
||||||
-- A week becomes whichever month the week's thursday falls into.
|
-- A week becomes whichever month the week's thursday falls into.
|
||||||
-- A year becomes all (unlimited).
|
-- A year becomes all (unlimited).
|
||||||
-- Growing an unlimited period, or a non-standard period (arbitrary dates) has no effect.
|
-- Non-standard periods (arbitrary dates, or open-ended) are unaffected.
|
||||||
periodGrow :: Period -> Period
|
periodGrow :: Period -> Period
|
||||||
periodGrow (DayPeriod b) = WeekPeriod $ mondayBefore b
|
periodGrow (DayPeriod b) = WeekPeriod $ mondayBefore b
|
||||||
periodGrow (WeekPeriod b) = MonthPeriod y m
|
periodGrow (WeekPeriod b) = MonthPeriod y m
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user