7
7
*/
8
8
abstract class AbstractEaster extends AbstractProvider
9
9
{
10
+ /**
11
+ * Creating easter sunday
12
+ *
13
+ * @param $year
14
+ * @return \DateTime
15
+ */
16
+ private function createSunday ($ year )
17
+ {
18
+ $ easterSunday = new \DateTime ('21.03. ' . $ year );
19
+ $ easterSunday ->modify (sprintf ('+%d days ' , easter_days ($ year )));
20
+
21
+ return $ easterSunday ;
22
+ }
23
+
24
+ /**
25
+ * Creating Orthodox easter sunday
26
+ *
27
+ * @param $year
28
+ * @return \DateTime
29
+ */
30
+ private function createOrthodoxSunday ($ year )
31
+ {
32
+ $ a = $ year % 4 ;
33
+ $ b = $ year % 7 ;
34
+ $ c = $ year % 19 ;
35
+ $ d = (19 * $ c + 15 ) % 30 ;
36
+ $ e = (2 * $ a + 4 * $ b - $ d + 34 ) % 7 ;
37
+ $ month = floor (($ d + $ e + 114 ) / 31 );
38
+ $ day = (($ d + $ e + 114 ) % 31 ) + 1 ;
39
+
40
+ $ sunday = mktime (0 , 0 , 0 , $ month , $ day + 13 , $ year );
41
+
42
+ return new \DateTime (date ('Y-m-d ' , $ sunday ));
43
+ }
10
44
11
45
/**
12
46
* Returns all dates calculated by easter sunday
13
47
*
14
48
* @param int $year
49
+ * @param boolean $orthodox
15
50
*
16
51
* @return \DateTime[]
17
52
*/
18
- protected function getEasterDates ($ year )
53
+ protected function getEasterDates ($ year, $ orthodox = false )
19
54
{
20
- $ easterSunday = new \ DateTime ( ' 21.03. ' . $ year );
21
- $ easterSunday -> modify ( sprintf ( ' +%d days ' , easter_days ( $ year )));
55
+ $ easterSunday = $ orthodox ? $ this -> createOrthodoxSunday ( $ year ) : $ this -> createSunday ( $ year );
56
+
22
57
$ easterSunday ->setTimezone (new \DateTimeZone (date_default_timezone_get ()));
23
58
24
59
$ easterMonday = clone $ easterSunday ;
@@ -43,16 +78,16 @@ protected function getEasterDates($year)
43
78
$ corpusChristi ->modify ('+60 days ' );
44
79
45
80
return array (
46
- 'maundyThursday ' => $ maundyThursday ,
47
- 'easterSunday ' => $ easterSunday ,
48
- 'easterMonday ' => $ easterMonday ,
49
- 'saturday ' => $ saturday ,
50
- 'goodFriday ' => $ goodFriday ,
51
- 'ascensionDay ' => $ ascensionDay ,
81
+ 'maundyThursday ' => $ maundyThursday ,
82
+ 'easterSunday ' => $ easterSunday ,
83
+ 'easterMonday ' => $ easterMonday ,
84
+ 'saturday ' => $ saturday ,
85
+ 'goodFriday ' => $ goodFriday ,
86
+ 'ascensionDay ' => $ ascensionDay ,
52
87
'pentecostSaturday ' => $ pentecostSaturday ,
53
- 'pentecostSunday ' => $ pentecostSunday ,
54
- 'pentecostMonday ' => $ pentecostMonday ,
55
- 'corpusChristi ' => $ corpusChristi
88
+ 'pentecostSunday ' => $ pentecostSunday ,
89
+ 'pentecostMonday ' => $ pentecostMonday ,
90
+ 'corpusChristi ' => $ corpusChristi
56
91
);
57
92
}
58
93
0 commit comments