From 6b677616c417d6a609374ccb1322c33a036f6025 Mon Sep 17 00:00:00 2001 From: fizgiel Date: Wed, 17 Jan 2024 17:28:42 +0100 Subject: [PATCH 1/2] poland --- src/Countries/Poland.php | 43 +++++++++++++++ .../it_can_calculate_polish_holidays.snap | 54 +++++++++++++++++++ tests/Countries/PolandTest.php | 18 +++++++ 3 files changed, 115 insertions(+) create mode 100644 src/Countries/Poland.php create mode 100644 tests/.pest/snapshots/Countries/PolandTest/it_can_calculate_polish_holidays.snap create mode 100644 tests/Countries/PolandTest.php diff --git a/src/Countries/Poland.php b/src/Countries/Poland.php new file mode 100644 index 000000000..f91628e9c --- /dev/null +++ b/src/Countries/Poland.php @@ -0,0 +1,43 @@ + */ + protected function allHolidays(int $year): array + { + return array_merge([ + 'Nowy Rok' => '01-01', + 'Święto Trzech Króli' => '01-06', + 'Święto Pracy' => '05-01', + 'Święto Konstytucji 3 Maja' => '05-03', + 'Święto Wojska Polskiego, Wniebowzięcie Najświętszej Maryi Panny' => '08-15', + 'Wszystkich Świętych' => '11-01', + 'Święto Niepodległości' => '11-11', + 'Boże Narodzenie' => '12-25', + 'Boże Narodzenie' => '12-26', + ], $this->variableHolidays($year)); + } + + /** @return array */ + protected function variableHolidays(int $year): array + { + $easter = CarbonImmutable::createFromTimestamp(easter_date($year))->setTimezone('Europe/Warsaw'); + + return [ + 'Wielkanoc' => $easter, + 'Poniedziałek Wielkanocny' => $easter->addDay(), + 'Zielone Świątki' => $easter->addWeeks(7), + 'Boże Ciało' => $easter->addDays(60), + + ]; + } +} diff --git a/tests/.pest/snapshots/Countries/PolandTest/it_can_calculate_polish_holidays.snap b/tests/.pest/snapshots/Countries/PolandTest/it_can_calculate_polish_holidays.snap new file mode 100644 index 000000000..1842c45bf --- /dev/null +++ b/tests/.pest/snapshots/Countries/PolandTest/it_can_calculate_polish_holidays.snap @@ -0,0 +1,54 @@ +[ + { + "name": "Nowy Rok", + "date": "2024-01-01" + }, + { + "name": "Święto Trzech Króli", + "date": "2024-01-06" + }, + { + "name": "Święto Pracy", + "date": "2024-05-01" + }, + { + "name": "Święto Konstytucji 3 Maja", + "date": "2024-05-03" + }, + { + "name": "Święto Wojska Polskiego, Wniebowzięcie Najświętszej Maryi Panny", + "date": "2024-08-15" + }, + { + "name": "Wszystkich Świętych", + "date": "2024-11-01" + }, + { + "name": "Święto Niepodległości", + "date": "2024-11-11" + }, + { + "name": "Boże Narodzenie", + "date": "2024-12-25" + }, + { + "name": "Boże Narodzenie", + "date": "2024-12-26" + }, + { + "name": "Wielkanoc", + "date": "2024-03-31" + }, + { + "name": "Poniedziałek Wielkanocny", + "date": "2024-04-01" + }, + { + "name": "Zielone Świątki", + "date": "2024-05-19" + }, + { + "name": "Boże Ciało", + "date": "2024-05-30" + } +] \ No newline at end of file diff --git a/tests/Countries/PolandTest.php b/tests/Countries/PolandTest.php new file mode 100644 index 000000000..25a75ebc7 --- /dev/null +++ b/tests/Countries/PolandTest.php @@ -0,0 +1,18 @@ +get(); + + expect($holidays) + ->toBeArray() + ->not()->toBeEmpty(); + + expect(formatDates($holidays))->toMatchSnapshot(); +}); From 639790a7cba835fce154060771d6868552025288 Mon Sep 17 00:00:00 2001 From: Radoslaw Kowalewski Date: Sun, 21 Jan 2024 13:35:08 +0100 Subject: [PATCH 2/2] Fix polish holidays --- src/Countries/Poland.php | 5 +- .../it_can_calculate_polish_holidays.snap | 46 +++++++++---------- 2 files changed, 25 insertions(+), 26 deletions(-) diff --git a/src/Countries/Poland.php b/src/Countries/Poland.php index f91628e9c..b6e111ebe 100644 --- a/src/Countries/Poland.php +++ b/src/Countries/Poland.php @@ -11,7 +11,7 @@ public function countryCode(): string return 'pl'; } - /** @return array */ + /** @return array */ protected function allHolidays(int $year): array { return array_merge([ @@ -23,7 +23,7 @@ protected function allHolidays(int $year): array 'Wszystkich Świętych' => '11-01', 'Święto Niepodległości' => '11-11', 'Boże Narodzenie' => '12-25', - 'Boże Narodzenie' => '12-26', + 'Drugi Dzień Bożego Narodzenia' => '12-26', ], $this->variableHolidays($year)); } @@ -37,7 +37,6 @@ protected function variableHolidays(int $year): array 'Poniedziałek Wielkanocny' => $easter->addDay(), 'Zielone Świątki' => $easter->addWeeks(7), 'Boże Ciało' => $easter->addDays(60), - ]; } } diff --git a/tests/.pest/snapshots/Countries/PolandTest/it_can_calculate_polish_holidays.snap b/tests/.pest/snapshots/Countries/PolandTest/it_can_calculate_polish_holidays.snap index 1842c45bf..a14c2115a 100644 --- a/tests/.pest/snapshots/Countries/PolandTest/it_can_calculate_polish_holidays.snap +++ b/tests/.pest/snapshots/Countries/PolandTest/it_can_calculate_polish_holidays.snap @@ -4,51 +4,51 @@ "date": "2024-01-01" }, { - "name": "Święto Trzech Króli", + "name": "\u015awi\u0119to Trzech Kr\u00f3li", "date": "2024-01-06" }, { - "name": "Święto Pracy", - "date": "2024-05-01" + "name": "Wielkanoc", + "date": "2024-03-31" }, { - "name": "Święto Konstytucji 3 Maja", - "date": "2024-05-03" + "name": "Poniedzia\u0142ek Wielkanocny", + "date": "2024-04-01" }, { - "name": "Święto Wojska Polskiego, Wniebowzięcie Najświętszej Maryi Panny", - "date": "2024-08-15" + "name": "\u015awi\u0119to Pracy", + "date": "2024-05-01" }, { - "name": "Wszystkich Świętych", - "date": "2024-11-01" + "name": "\u015awi\u0119to Konstytucji 3 Maja", + "date": "2024-05-03" }, { - "name": "Święto Niepodległości", - "date": "2024-11-11" + "name": "Zielone \u015awi\u0105tki", + "date": "2024-05-19" }, { - "name": "Boże Narodzenie", - "date": "2024-12-25" + "name": "Bo\u017ce Cia\u0142o", + "date": "2024-05-30" }, { - "name": "Boże Narodzenie", - "date": "2024-12-26" + "name": "\u015awi\u0119to Wojska Polskiego, Wniebowzi\u0119cie Naj\u015bwi\u0119tszej Maryi Panny", + "date": "2024-08-15" }, { - "name": "Wielkanoc", - "date": "2024-03-31" + "name": "Wszystkich \u015awi\u0119tych", + "date": "2024-11-01" }, { - "name": "Poniedziałek Wielkanocny", - "date": "2024-04-01" + "name": "\u015awi\u0119to Niepodleg\u0142o\u015bci", + "date": "2024-11-11" }, { - "name": "Zielone Świątki", - "date": "2024-05-19" + "name": "Bo\u017ce Narodzenie", + "date": "2024-12-25" }, { - "name": "Boże Ciało", - "date": "2024-05-30" + "name": "Drugi Dzie\u0144 Bo\u017cego Narodzenia", + "date": "2024-12-26" } ] \ No newline at end of file