From 1068902d7c16c4dc4adeb579a0a4e4b266eeb233 Mon Sep 17 00:00:00 2001 From: Niels Vanpachtenbeke <10651054+Nielsvanpach@users.noreply.github.com> Date: Thu, 8 Feb 2024 11:35:16 +0100 Subject: [PATCH] cleanup Germany --- src/Countries/Germany.php | 78 +++++++++++++++++++-------------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/src/Countries/Germany.php b/src/Countries/Germany.php index e0b61f282..fda0dc46e 100644 --- a/src/Countries/Germany.php +++ b/src/Countries/Germany.php @@ -16,25 +16,48 @@ public function countryCode(): string return 'de'; } - private function getRepentanceAndPrayerDay(int $year): string + protected function allHolidays(int $year): array + { + return array_merge([ + 'Neujahr' => '01-01', + 'Tag der Arbeit' => '05-01', + '1. Weihnachtstag' => '12-25', + '2. Weihnachtstag' => '12-26', + ], + $this->variableHolidays($year), + $this->historicalHolidays($year), + $this->regionHolidays($year) + ); + } + + /** @return array */ + protected function variableHolidays(int $year): array { - $repentanceAndPrayerDay = new CarbonImmutable('next wednesday '.$year.'-11-15', 'Europe/Berlin'); + $easter = $this->easter($year); - return $repentanceAndPrayerDay->format('m-d'); + return [ + 'Karfreitag' => $easter->subDays(2), + 'Ostermontag' => $easter->addDay(), + 'Himmelfahrt' => $easter->addDays(39), + 'Pfingstmontag' => $easter->addDays(50), + ]; } /** @return array */ protected function historicalHolidays(int $year): array { $historicalHolidays = []; + if ($year >= 1954 && $year <= 1990) { $historicalHolidays['Tag der deutschen Einheit'] = '06-17'; } else { $historicalHolidays['Tag der deutschen Einheit'] = '10-03'; } + if ($year >= 1990 && $year <= 1994) { $historicalHolidays['Buß- und Bettag'] = $this->getRepentanceAndPrayerDay($year); } + if ($year === 2017) { $historicalHolidays['Reformationstag'] = '10-31'; } @@ -42,32 +65,6 @@ protected function historicalHolidays(int $year): array return $historicalHolidays; } - /** @return array */ - protected function allHolidays(int $year): array - { - - return array_merge([ - 'Neujahr' => '01-01', - 'Tag der Arbeit' => '05-01', - '1. Weihnachtstag' => '12-25', - '2. Weihnachtstag' => '12-26', - ], $this->variableHolidays($year), $this->historicalHolidays($year), $this->regionHolidays($year)); - } - - /** @return array */ - protected function variableHolidays(int $year): array - { - - $easter = $this->easter($year); - - return [ - 'Karfreitag' => $easter->subDays(2), - 'Ostermontag' => $easter->addDay(), - 'Himmelfahrt' => $easter->addDays(39), - 'Pfingstmontag' => $easter->addDays(50), - ]; - } - /** @return array */ protected function regionHolidays(int $year): array { @@ -111,12 +108,12 @@ protected function regionHolidays(int $year): array 'Reformationstag' => '10-31', 'Pfingstsonntag' => $easter->addDays(49), ]; - } else { - return [ - 'Ostersonntag' => $easter, - 'Pfingstsonntag' => $easter->addDays(49), - ]; } + + return [ + 'Ostersonntag' => $easter, + 'Pfingstsonntag' => $easter->addDays(49), + ]; case 'DE-HB': case 'DE-HH': case 'DE-NI': @@ -125,12 +122,10 @@ protected function regionHolidays(int $year): array return [ 'Reformationstag' => '10-31', ]; - } else { - return [ - - ]; } + return []; + case 'DE-HE': return [ 'Ostersonntag' => $easter, @@ -142,6 +137,7 @@ protected function regionHolidays(int $year): array if ($year >= 1990) { $mvHolidays['Reformationstag'] = '10-31'; } + if ($year >= 2023) { $mvHolidays['Internationaler Frauentag'] = '03-08'; } @@ -191,9 +187,13 @@ protected function regionHolidays(int $year): array } return $thHolidays; - } return []; } + + protected function getRepentanceAndPrayerDay(int $year): CarbonImmutable + { + return (new CarbonImmutable('next wednesday '.$year.'-11-15'))->startOfDay(); + } }