Skip to content

Commit

Permalink
Merge pull request #25 from mpociot/add_repentance_day
Browse files Browse the repository at this point in the history
Add repentance day
  • Loading branch information
BenjaminPaap authored Nov 21, 2017
2 parents 5270683 + a9625ae commit ce9294e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
18 changes: 18 additions & 0 deletions src/Provider/DE.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public function getHolidaysByYear($year)
{
$easter = $this->getEasterDates($year);

$repentanceDay = $this->getDayOfRepentance($year);

// 500th anniversay of the Reformation
// @see https://de.wikipedia.org/wiki/Reformationstag#Deutschland
if (2017 === $year) {
Expand Down Expand Up @@ -89,10 +91,26 @@ public function getHolidaysByYear($year)
self::STATE_NW,
self::STATE_RP,
self::STATE_SL,
)),
$repentanceDay->format(self::DATE_FORMAT) => $this->createData('Buß- und Bettag', array(
self::STATE_SN
))
);

return $holidays;
}

/**
* The German day of repentance is the wednesday befor the 23rd of November
* @param int $year
* @return \DateTime
*/
public function getDayOfRepentance($year)
{
$date = new \DateTime($year.'-11-23');
$date->modify('previous wednesday');

return $date;
}

}
4 changes: 3 additions & 1 deletion test/Provider/DETest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ public function dateProvider()
array('2017-10-31', DE::STATE_SH, array('name' => 'Reformationstag')),
array('2017-10-31', DE::STATE_BB, array('name' => 'Reformationstag')),
array('2018-10-31', DE::STATE_SH, null),
array('2018-10-31', DE::STATE_BB, array('name' => 'Reformationstag')),
array('2018-11-21', DE::STATE_BB, null),
array('2018-11-21', DE::STATE_SN, array('name' => 'Buß- und Bettag')),
array('2018-10-31', DE::STATE_SH, null),
);
}
}

0 comments on commit ce9294e

Please sign in to comment.