Skip to content

Commit

Permalink
cleanup Germany
Browse files Browse the repository at this point in the history
  • Loading branch information
Nielsvanpach committed Feb 8, 2024
1 parent c1bf359 commit 1068902
Showing 1 changed file with 39 additions and 39 deletions.
78 changes: 39 additions & 39 deletions src/Countries/Germany.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,58 +16,55 @@ 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<string, CarbonImmutable> */
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<string, string> */
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';
}

return $historicalHolidays;
}

/** @return array<string, CarbonImmutable|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<string, CarbonImmutable> */
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<string, CarbonImmutable|string> */
protected function regionHolidays(int $year): array
{
Expand Down Expand Up @@ -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':
Expand All @@ -125,12 +122,10 @@ protected function regionHolidays(int $year): array
return [
'Reformationstag' => '10-31',
];
} else {
return [

];
}

return [];

case 'DE-HE':
return [
'Ostersonntag' => $easter,
Expand All @@ -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';
}
Expand Down Expand Up @@ -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();
}
}

0 comments on commit 1068902

Please sign in to comment.