Skip to content

Commit ce9294e

Browse files
authored
Merge pull request #25 from mpociot/add_repentance_day
Add repentance day
2 parents 5270683 + a9625ae commit ce9294e

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/Provider/DE.php

+18
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ public function getHolidaysByYear($year)
3737
{
3838
$easter = $this->getEasterDates($year);
3939

40+
$repentanceDay = $this->getDayOfRepentance($year);
41+
4042
// 500th anniversay of the Reformation
4143
// @see https://de.wikipedia.org/wiki/Reformationstag#Deutschland
4244
if (2017 === $year) {
@@ -89,10 +91,26 @@ public function getHolidaysByYear($year)
8991
self::STATE_NW,
9092
self::STATE_RP,
9193
self::STATE_SL,
94+
)),
95+
$repentanceDay->format(self::DATE_FORMAT) => $this->createData('Buß- und Bettag', array(
96+
self::STATE_SN
9297
))
9398
);
9499

95100
return $holidays;
96101
}
97102

103+
/**
104+
* The German day of repentance is the wednesday befor the 23rd of November
105+
* @param int $year
106+
* @return \DateTime
107+
*/
108+
public function getDayOfRepentance($year)
109+
{
110+
$date = new \DateTime($year.'-11-23');
111+
$date->modify('previous wednesday');
112+
113+
return $date;
114+
}
115+
98116
}

test/Provider/DETest.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ public function dateProvider()
3636
array('2017-10-31', DE::STATE_SH, array('name' => 'Reformationstag')),
3737
array('2017-10-31', DE::STATE_BB, array('name' => 'Reformationstag')),
3838
array('2018-10-31', DE::STATE_SH, null),
39-
array('2018-10-31', DE::STATE_BB, array('name' => 'Reformationstag')),
39+
array('2018-11-21', DE::STATE_BB, null),
40+
array('2018-11-21', DE::STATE_SN, array('name' => 'Buß- und Bettag')),
41+
array('2018-10-31', DE::STATE_SH, null),
4042
);
4143
}
4244
}

0 commit comments

Comments
 (0)