{-# LANGUAGE Safe #-}
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 -> Day
sundayAfter Day
day = Integer -> Day -> Day
addDays (Integer
7 forall a. Num a => a -> a -> a
- (forall a. Integral a => a -> a -> a
mod (Day -> Integer
toModifiedJulianDay Day
day forall a. Num a => a -> a -> a
+ Integer
3) Integer
7)) Day
day
orthodoxPaschalMoon :: Year -> Day
orthodoxPaschalMoon :: Integer -> Day
orthodoxPaschalMoon Integer
year = Integer -> Day -> Day
addDays (-Integer
shiftedEpact) (Integer -> MonthOfYear -> MonthOfYear -> Day
fromJulian Integer
jyear MonthOfYear
4 MonthOfYear
19)
where
shiftedEpact :: Integer
shiftedEpact = forall a. Integral a => a -> a -> a
mod (Integer
14 forall a. Num a => a -> a -> a
+ Integer
11 forall a. Num a => a -> a -> a
* (forall a. Integral a => a -> a -> a
mod Integer
year Integer
19)) Integer
30
jyear :: Integer
jyear =
if Integer
year forall a. Ord a => a -> a -> Bool
> Integer
0
then Integer
year
else Integer
year forall a. Num a => a -> a -> a
- Integer
1
orthodoxEaster :: Year -> Day
orthodoxEaster :: Integer -> Day
orthodoxEaster = Day -> Day
sundayAfter forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Day
orthodoxPaschalMoon
gregorianPaschalMoon :: Year -> Day
gregorianPaschalMoon :: Integer -> Day
gregorianPaschalMoon Integer
year = Integer -> Day -> Day
addDays (-Integer
adjustedEpact) (Integer -> MonthOfYear -> MonthOfYear -> Day
fromGregorian Integer
year MonthOfYear
4 MonthOfYear
19)
where
century :: Integer
century = (forall a. Integral a => a -> a -> a
div Integer
year Integer
100) forall a. Num a => a -> a -> a
+ Integer
1
shiftedEpact :: Integer
shiftedEpact = forall a. Integral a => a -> a -> a
mod (Integer
14 forall a. Num a => a -> a -> a
+ Integer
11 forall a. Num a => a -> a -> a
* (forall a. Integral a => a -> a -> a
mod Integer
year Integer
19) forall a. Num a => a -> a -> a
- (forall a. Integral a => a -> a -> a
div (Integer
3 forall a. Num a => a -> a -> a
* Integer
century) Integer
4) forall a. Num a => a -> a -> a
+ (forall a. Integral a => a -> a -> a
div (Integer
5 forall a. Num a => a -> a -> a
+ Integer
8 forall a. Num a => a -> a -> a
* Integer
century) Integer
25)) Integer
30
adjustedEpact :: Integer
adjustedEpact =
if Integer
shiftedEpact forall a. Eq a => a -> a -> Bool
== Integer
0 Bool -> Bool -> Bool
|| ((Integer
shiftedEpact forall a. Eq a => a -> a -> Bool
== Integer
1) Bool -> Bool -> Bool
&& (forall a. Integral a => a -> a -> a
mod Integer
year Integer
19 forall a. Ord a => a -> a -> Bool
< Integer
10))
then Integer
shiftedEpact forall a. Num a => a -> a -> a
+ Integer
1
else Integer
shiftedEpact
gregorianEaster :: Year -> Day
gregorianEaster :: Integer -> Day
gregorianEaster = Day -> Day
sundayAfter forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Day
gregorianPaschalMoon