From c2fdb0858432022469397f5dfcf40d0482056da6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Ko=CC=88rner?= Date: Wed, 5 Jul 2017 21:25:41 +0200 Subject: [PATCH] Fix #19: [DE] 500th anniversay of the Reformation --- .../Holiday/Provider/AbstractProvider.php | 2 +- lib/Checkdomain/Holiday/Provider/DE.php | 22 +++++++++++++------ tests/Checkdomain/Holiday/Provider/DETest.php | 6 +++++ 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/lib/Checkdomain/Holiday/Provider/AbstractProvider.php b/lib/Checkdomain/Holiday/Provider/AbstractProvider.php index a879a6f..04f4413 100644 --- a/lib/Checkdomain/Holiday/Provider/AbstractProvider.php +++ b/lib/Checkdomain/Holiday/Provider/AbstractProvider.php @@ -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); diff --git a/lib/Checkdomain/Holiday/Provider/DE.php b/lib/Checkdomain/Holiday/Provider/DE.php index fa43d7c..db82a53 100644 --- a/lib/Checkdomain/Holiday/Provider/DE.php +++ b/lib/Checkdomain/Holiday/Provider/DE.php @@ -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'), @@ -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, diff --git a/tests/Checkdomain/Holiday/Provider/DETest.php b/tests/Checkdomain/Holiday/Provider/DETest.php index d3fa7d0..cbf0782 100644 --- a/tests/Checkdomain/Holiday/Provider/DETest.php +++ b/tests/Checkdomain/Holiday/Provider/DETest.php @@ -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')), ); } }