module Holidays.DateTransform (
substituteRule,
sundayRule,
DateTransform,
) where
import Data.Set qualified as S
import Data.Time
import Holidays.Base
import Holidays.DateFinder
type DateTransform = S.Set Holiday -> Holiday -> Holiday
sundayRule :: DateTransform
sundayRule :: DateTransform
sundayRule Set Holiday
_ Holiday
d = if Day -> DayOfWeek
dayOfWeek Day
h DayOfWeek -> DayOfWeek -> Bool
forall a. Eq a => a -> a -> Bool
== DayOfWeek
Sunday then Holiday
d {holidayValue :: Day
holidayValue = Integer -> Day -> Day
addDays Integer
1 Day
h} else Holiday
d
where
h :: Day
h = Holiday -> Day
holidayValue Holiday
d
substituteRule :: DateTransform
substituteRule :: DateTransform
substituteRule = [DayOfWeek] -> DateTransform
nextOpenDay [DayOfWeek
Saturday, DayOfWeek
Sunday]