Skip to content

Commit

Permalink
Fix #19: [DE] 500th anniversay of the Reformation
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianKoerner committed Jul 5, 2017
1 parent 5c136b8 commit c2fdb08
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/Checkdomain/Holiday/Provider/AbstractProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function getHolidayByDate(\DateTime $date, $state = null)
{
$day = $date->format(self::DATE_FORMAT);

$holidays = $this->getHolidaysByYear($date->format('Y'));
$holidays = $this->getHolidaysByYear(intval($date->format('Y')));

if (isset($holidays[$day])) {
$holiday = $this->createModelFromData($holidays[$day], $date);
Expand Down
22 changes: 15 additions & 7 deletions lib/Checkdomain/Holiday/Provider/DE.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,20 @@ public function getHolidaysByYear($year)
{
$easter = $this->getEasterDates($year);

// 500th anniversay of the Reformation
// @see https://de.wikipedia.org/wiki/Reformationstag#Deutschland
if (2017 === $year) {
$reformationDayStates = null;
} else {
$reformationDayStates = array(
self::STATE_BB,
self::STATE_MV,
self::STATE_SN,
self::STATE_ST,
self::STATE_TH,
);
}

$holidays = array(
// Fixed dates
'01-01' => $this->createData('Neujahr'),
Expand All @@ -51,13 +65,7 @@ public function getHolidaysByYear($year)
self::STATE_BY,
self::STATE_ST,
)),
'10-31' => $this->createData('Reformationstag', array(
self::STATE_BB,
self::STATE_MV,
self::STATE_SN,
self::STATE_ST,
self::STATE_TH,
)),
'10-31' => $this->createData('Reformationstag', $reformationDayStates),
'11-01' => $this->createData('Allerheiligen', array(
self::STATE_BW,
self::STATE_BY,
Expand Down
6 changes: 6 additions & 0 deletions tests/Checkdomain/Holiday/Provider/DETest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ public function dateProvider()
array('2014-06-19', DE::STATE_SH, null),
array('2014-11-01', DE::STATE_BW, array('name' => 'Allerheiligen')),
array('2014-11-01', DE::STATE_SH, null),
array('2016-10-31', DE::STATE_SH, null),
array('2016-10-31', DE::STATE_BB, array('name' => 'Reformationstag')),
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')),
);
}
}

0 comments on commit c2fdb08

Please sign in to comment.