diff --git a/src/Actions/Belgium.php b/src/Actions/Belgium.php index ae72d0020..942ec8e33 100644 --- a/src/Actions/Belgium.php +++ b/src/Actions/Belgium.php @@ -9,6 +9,7 @@ class Belgium implements Executable { protected int $year; + /** @return array */ public function execute(int $year): array { $this->year = $year; @@ -32,7 +33,7 @@ protected function ensureYearCanBeCalculated(): void } } - /** @return array */ + /** @return array */ protected function fixedHolidays(): array { $dates = [ @@ -46,21 +47,22 @@ protected function fixedHolidays(): array ]; foreach ($dates as $name => $date) { - $dates[$name] = "{$date}-{$this->year}"; + $dates[$name] = CarbonImmutable::createFromFormat('d-m-Y', "{$date}-{$this->year}"); } return $dates; } - /** @return array */ + /** @return array */ protected function variableHolidays(): array { - $easter = CarbonImmutable::createFromTimestampUTC(easter_date($this->year)); + $easter = CarbonImmutable::createFromTimestamp(easter_date($this->year)) + ->setTimezone('Europe/Brussels'); return [ - 'Paasmaandag' => $easter->addDay()->format('d-m-Y'), - 'OH Hemelvaart' => $easter->addDays(39)->format('d-m-Y'), - 'Pinkstermaandag' => $easter->addDays(50)->format('d-m-Y'), + 'Paasmaandag' => $easter->addDay(), + 'OH Hemelvaart' => $easter->addDays(39), + 'Pinkstermaandag' => $easter->addDays(50), ]; } } diff --git a/src/Holidays.php b/src/Holidays.php index bba68ceb5..00ab1d9a1 100755 --- a/src/Holidays.php +++ b/src/Holidays.php @@ -8,7 +8,7 @@ class Holidays { - /** @return array */ + /** @return array */ protected array $holidays = []; protected int $year; @@ -63,13 +63,13 @@ protected function calculate(): self $this->holidays = $action->execute($this->year); - asort($this->holidays); + uasort($this->holidays, fn (CarbonImmutable $a, CarbonImmutable $b) => $a->timestamp <=> $b->timestamp); return $this; } /** - * @param array $dates + * @param array $dates * @return array */ protected function format(array $dates): array @@ -79,7 +79,7 @@ protected function format(array $dates): array foreach ($dates as $name => $date) { $response[] = [ 'name' => $name, - 'date' => $date, + 'date' => $date->format('d-m-Y'), ]; } diff --git a/tests/.pest/snapshots/HolidaysTest/it_can_get_all_holidays_of_2022.snap b/tests/.pest/snapshots/HolidaysTest/it_can_get_all_holidays_of_2022.snap index 3d0974e0c..ff96a5106 100644 --- a/tests/.pest/snapshots/HolidaysTest/it_can_get_all_holidays_of_2022.snap +++ b/tests/.pest/snapshots/HolidaysTest/it_can_get_all_holidays_of_2022.snap @@ -3,37 +3,37 @@ "name": "Nieuwjaar", "date": "01-01-2022" }, + { + "name": "Paasmaandag", + "date": "18-04-2022" + }, { "name": "Dag van de Arbeid", - "date": "01-01-2022" + "date": "01-05-2022" }, { - "name": "Allerheiligen", - "date": "01-11-2022" + "name": "OH Hemelvaart", + "date": "26-05-2022" }, { "name": "Pinkstermaandag", - "date": "05-06-2022" + "date": "06-06-2022" }, { - "name": "Wapenstilstand", - "date": "11-11-2022" + "name": "Nationale Feestdag", + "date": "21-07-2022" }, { "name": "OLV Hemelvaart", "date": "15-08-2022" }, { - "name": "Paasmaandag", - "date": "17-04-2022" - }, - { - "name": "Nationale Feestdag", - "date": "21-07-2022" + "name": "Allerheiligen", + "date": "01-11-2022" }, { - "name": "OH Hemelvaart", - "date": "25-05-2022" + "name": "Wapenstilstand", + "date": "11-11-2022" }, { "name": "Kerstmis", diff --git a/tests/.pest/snapshots/HolidaysTest/it_can_get_all_holidays_of_2023.snap b/tests/.pest/snapshots/HolidaysTest/it_can_get_all_holidays_of_2023.snap index bbd37a43e..bb80f365a 100644 --- a/tests/.pest/snapshots/HolidaysTest/it_can_get_all_holidays_of_2023.snap +++ b/tests/.pest/snapshots/HolidaysTest/it_can_get_all_holidays_of_2023.snap @@ -3,40 +3,40 @@ "name": "Nieuwjaar", "date": "01-01-2023" }, + { + "name": "Paasmaandag", + "date": "10-04-2023" + }, { "name": "Dag van de Arbeid", - "date": "01-01-2023" + "date": "01-05-2023" }, { - "name": "Allerheiligen", - "date": "01-11-2023" + "name": "OH Hemelvaart", + "date": "18-05-2023" }, { - "name": "Paasmaandag", - "date": "09-04-2023" + "name": "Pinkstermaandag", + "date": "29-05-2023" }, { - "name": "Wapenstilstand", - "date": "11-11-2023" + "name": "Nationale Feestdag", + "date": "21-07-2023" }, { "name": "OLV Hemelvaart", "date": "15-08-2023" }, { - "name": "OH Hemelvaart", - "date": "17-05-2023" + "name": "Allerheiligen", + "date": "01-11-2023" }, { - "name": "Nationale Feestdag", - "date": "21-07-2023" + "name": "Wapenstilstand", + "date": "11-11-2023" }, { "name": "Kerstmis", "date": "25-12-2023" - }, - { - "name": "Pinkstermaandag", - "date": "28-05-2023" } ] \ No newline at end of file diff --git a/tests/.pest/snapshots/HolidaysTest/it_can_get_all_holidays_of_2025.snap b/tests/.pest/snapshots/HolidaysTest/it_can_get_all_holidays_of_2025.snap index 88b8bd1e4..98c0a7d09 100644 --- a/tests/.pest/snapshots/HolidaysTest/it_can_get_all_holidays_of_2025.snap +++ b/tests/.pest/snapshots/HolidaysTest/it_can_get_all_holidays_of_2025.snap @@ -3,40 +3,40 @@ "name": "Nieuwjaar", "date": "01-01-2025" }, + { + "name": "Paasmaandag", + "date": "21-04-2025" + }, { "name": "Dag van de Arbeid", - "date": "01-01-2025" + "date": "01-05-2025" }, { - "name": "Allerheiligen", - "date": "01-11-2025" + "name": "OH Hemelvaart", + "date": "29-05-2025" }, { "name": "Pinkstermaandag", - "date": "08-06-2025" + "date": "09-06-2025" }, { - "name": "Wapenstilstand", - "date": "11-11-2025" + "name": "Nationale Feestdag", + "date": "21-07-2025" }, { "name": "OLV Hemelvaart", "date": "15-08-2025" }, { - "name": "Paasmaandag", - "date": "20-04-2025" + "name": "Allerheiligen", + "date": "01-11-2025" }, { - "name": "Nationale Feestdag", - "date": "21-07-2025" + "name": "Wapenstilstand", + "date": "11-11-2025" }, { "name": "Kerstmis", "date": "25-12-2025" - }, - { - "name": "OH Hemelvaart", - "date": "28-05-2025" } ] \ No newline at end of file diff --git a/tests/.pest/snapshots/HolidaysTest/it_can_get_all_holidays_of_another_year_and_a_specific_country.snap b/tests/.pest/snapshots/HolidaysTest/it_can_get_all_holidays_of_another_year_and_a_specific_country.snap index f5ac5e4b6..f9d3c2bfe 100644 --- a/tests/.pest/snapshots/HolidaysTest/it_can_get_all_holidays_of_another_year_and_a_specific_country.snap +++ b/tests/.pest/snapshots/HolidaysTest/it_can_get_all_holidays_of_another_year_and_a_specific_country.snap @@ -4,39 +4,39 @@ "date": "01-01-2024" }, { - "name": "Dag van de Arbeid", - "date": "01-01-2024" + "name": "Paasmaandag", + "date": "01-04-2024" }, { - "name": "Allerheiligen", - "date": "01-11-2024" + "name": "Dag van de Arbeid", + "date": "01-05-2024" }, { "name": "OH Hemelvaart", - "date": "08-05-2024" + "date": "09-05-2024" }, { - "name": "Wapenstilstand", - "date": "11-11-2024" + "name": "Pinkstermaandag", + "date": "20-05-2024" + }, + { + "name": "Nationale Feestdag", + "date": "21-07-2024" }, { "name": "OLV Hemelvaart", "date": "15-08-2024" }, { - "name": "Pinkstermaandag", - "date": "19-05-2024" + "name": "Allerheiligen", + "date": "01-11-2024" }, { - "name": "Nationale Feestdag", - "date": "21-07-2024" + "name": "Wapenstilstand", + "date": "11-11-2024" }, { "name": "Kerstmis", "date": "25-12-2024" - }, - { - "name": "Paasmaandag", - "date": "31-03-2024" } ] \ No newline at end of file diff --git a/tests/.pest/snapshots/HolidaysTest/it_can_get_all_holidays_of_the_current_year.snap b/tests/.pest/snapshots/HolidaysTest/it_can_get_all_holidays_of_the_current_year.snap index f5ac5e4b6..f9d3c2bfe 100644 --- a/tests/.pest/snapshots/HolidaysTest/it_can_get_all_holidays_of_the_current_year.snap +++ b/tests/.pest/snapshots/HolidaysTest/it_can_get_all_holidays_of_the_current_year.snap @@ -4,39 +4,39 @@ "date": "01-01-2024" }, { - "name": "Dag van de Arbeid", - "date": "01-01-2024" + "name": "Paasmaandag", + "date": "01-04-2024" }, { - "name": "Allerheiligen", - "date": "01-11-2024" + "name": "Dag van de Arbeid", + "date": "01-05-2024" }, { "name": "OH Hemelvaart", - "date": "08-05-2024" + "date": "09-05-2024" }, { - "name": "Wapenstilstand", - "date": "11-11-2024" + "name": "Pinkstermaandag", + "date": "20-05-2024" + }, + { + "name": "Nationale Feestdag", + "date": "21-07-2024" }, { "name": "OLV Hemelvaart", "date": "15-08-2024" }, { - "name": "Pinkstermaandag", - "date": "19-05-2024" + "name": "Allerheiligen", + "date": "01-11-2024" }, { - "name": "Nationale Feestdag", - "date": "21-07-2024" + "name": "Wapenstilstand", + "date": "11-11-2024" }, { "name": "Kerstmis", "date": "25-12-2024" - }, - { - "name": "Paasmaandag", - "date": "31-03-2024" } ] \ No newline at end of file