module Data.Time.Calendar.Easter
(
sundayAfter,
orthodoxPaschalMoon,orthodoxEaster,
gregorianPaschalMoon,gregorianEaster
) where
import Data.Time.Calendar
import Data.Time.Calendar.Julian
sundayAfter :: Day -> Day
sundayAfter day = addDays (7 (mod (toModifiedJulianDay day + 3) 7)) day
orthodoxPaschalMoon :: Integer -> Day
orthodoxPaschalMoon year = addDays ( shiftedEpact) (fromJulian jyear 4 19) where
shiftedEpact = mod (14 + 11 * (mod year 19)) 30
jyear = if year > 0 then year else year 1
orthodoxEaster :: Integer -> Day
orthodoxEaster = sundayAfter . orthodoxPaschalMoon
gregorianPaschalMoon :: Integer -> Day
gregorianPaschalMoon year = addDays ( adjustedEpact) (fromGregorian year 4 19) where
century = (div year 100) + 1
shiftedEpact = mod (14 + 11 * (mod year 19) (div (3 * century) 4) + (div (5 + 8 * century) 25)) 30
adjustedEpact = if shiftedEpact == 0 || ((shiftedEpact == 1) && (mod year 19 < 10)) then shiftedEpact + 1 else shiftedEpact
gregorianEaster :: Integer -> Day
gregorianEaster = sundayAfter . gregorianPaschalMoon