From ce71e6d58823b0198f953408e9b36206cc5e0c60 Mon Sep 17 00:00:00 2001 From: Vojtech Date: Wed, 17 Jan 2024 17:08:54 +0100 Subject: [PATCH 1/3] add: czech holidays --- src/Countries/Czechia.php | 43 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/Countries/Czechia.php diff --git a/src/Countries/Czechia.php b/src/Countries/Czechia.php new file mode 100644 index 000000000..c3a17f99b --- /dev/null +++ b/src/Countries/Czechia.php @@ -0,0 +1,43 @@ + */ + protected function allHolidays(int $year): array + { + return array_merge([ + 'Den obnovy samostatného českého státu' => '01-01', + 'Svátek práce' => '05-01', + 'Den vítězství' => '05-08', + 'Den slovanských věrozvěstů Cyrila a Metoděje' => '07-05', + 'Den upálení mistra Jana Husa' => '07-06', + 'Den české státnosti' => '09-28', + 'Den vzniku samostatného československého státu' => '10-28', + 'Den boje za svobodu a demokracii a Mezinárodní den studentstva' => '11-17', + 'Štědrý den' => '12-24', + '1. svátek vánoční' => '12-25', + '2. svátek vánoční' => '12-26', + ], $this->variableHolidays($year)); + } + + /** @return array */ + protected function variableHolidays(int $year): array + { + $easter = CarbonImmutable::createFromTimestamp(easter_date($year)) + ->setTimezone('Europe/Prague'); + + return [ + 'Velikonoční pondělí' => $easter->addDay(), + 'Velký pátek' => $easter->subDays(2), + ]; + } +} From b5be0c1c2027c6a8e91b1cc96e2aae266c25a3fa Mon Sep 17 00:00:00 2001 From: Vojtech Date: Wed, 17 Jan 2024 17:17:00 +0100 Subject: [PATCH 2/3] add: czechia test --- .../it_can_calculate_czech_holidays.snap | 54 +++++++++++++++++++ tests/Countries/CzechiaTest.php | 18 +++++++ 2 files changed, 72 insertions(+) create mode 100644 tests/.pest/snapshots/Countries/CzechiaTest/it_can_calculate_czech_holidays.snap create mode 100644 tests/Countries/CzechiaTest.php diff --git a/tests/.pest/snapshots/Countries/CzechiaTest/it_can_calculate_czech_holidays.snap b/tests/.pest/snapshots/Countries/CzechiaTest/it_can_calculate_czech_holidays.snap new file mode 100644 index 000000000..9e3ba56a8 --- /dev/null +++ b/tests/.pest/snapshots/Countries/CzechiaTest/it_can_calculate_czech_holidays.snap @@ -0,0 +1,54 @@ +[ + { + "name": "Den obnovy samostatn\u00e9ho \u010desk\u00e9ho st\u00e1tu", + "date": "2024-01-01" + }, + { + "name": "Velk\u00fd p\u00e1tek", + "date": "2024-03-29" + }, + { + "name": "Velikono\u010dn\u00ed pond\u011bl\u00ed", + "date": "2024-04-01" + }, + { + "name": "Sv\u00e1tek pr\u00e1ce", + "date": "2024-05-01" + }, + { + "name": "Den v\u00edt\u011bzstv\u00ed", + "date": "2024-05-08" + }, + { + "name": "Den slovansk\u00fdch v\u011brozv\u011bst\u016f Cyrila a Metod\u011bje", + "date": "2024-07-05" + }, + { + "name": "Den up\u00e1len\u00ed mistra Jana Husa", + "date": "2024-07-06" + }, + { + "name": "Den \u010desk\u00e9 st\u00e1tnosti", + "date": "2024-09-28" + }, + { + "name": "Den vzniku samostatn\u00e9ho \u010deskoslovensk\u00e9ho st\u00e1tu", + "date": "2024-10-28" + }, + { + "name": "Den boje za svobodu a demokracii a Mezin\u00e1rodn\u00ed den studentstva", + "date": "2024-11-17" + }, + { + "name": "\u0160t\u011bdr\u00fd den", + "date": "2024-12-24" + }, + { + "name": "1. sv\u00e1tek v\u00e1no\u010dn\u00ed", + "date": "2024-12-25" + }, + { + "name": "2. sv\u00e1tek v\u00e1no\u010dn\u00ed", + "date": "2024-12-26" + } +] \ No newline at end of file diff --git a/tests/Countries/CzechiaTest.php b/tests/Countries/CzechiaTest.php new file mode 100644 index 000000000..a23bac978 --- /dev/null +++ b/tests/Countries/CzechiaTest.php @@ -0,0 +1,18 @@ +get(); + + expect($holidays) + ->toBeArray() + ->not()->toBeEmpty(); + + expect(formatDates($holidays))->toMatchSnapshot(); +}); \ No newline at end of file From 3a73419f09d9bed15fb28217ee8e834313304cca Mon Sep 17 00:00:00 2001 From: Vojtech Rerabek Date: Thu, 18 Jan 2024 15:21:41 +0100 Subject: [PATCH 3/3] remove: docblock --- src/Countries/Czechia.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Countries/Czechia.php b/src/Countries/Czechia.php index c3a17f99b..f0cce6f00 100644 --- a/src/Countries/Czechia.php +++ b/src/Countries/Czechia.php @@ -11,7 +11,6 @@ public function countryCode(): string return 'cz'; } - /** @return array */ protected function allHolidays(int $year): array { return array_merge([