From 8c496df7e3860435f79f23de1d7a94bf2c84200e Mon Sep 17 00:00:00 2001 From: mauricius Date: Wed, 17 Jan 2024 18:02:34 +0100 Subject: [PATCH 1/5] add: italian holidays --- src/Countries/Italy.php | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/Countries/Italy.php diff --git a/src/Countries/Italy.php b/src/Countries/Italy.php new file mode 100644 index 000000000..abfc530ec --- /dev/null +++ b/src/Countries/Italy.php @@ -0,0 +1,41 @@ + */ + protected function allHolidays(int $year): array + { + return array_merge([ + 'Capodanno' => '01-01', + 'Epifania' => '01-06', + 'Liberazione dal nazifascismo' => '04-25', + 'Festa del lavoro' => '05-01', + 'Festa della Repubblica' => '06-02', + 'Assunzione di Maria' => '08-15', + 'Ognissanti' => '11-01', + 'Immacolata Concezione' => '12-08', + 'Natale di Gesù' => '12-25', + 'Santo Stefano' => '12-26', + ], $this->variableHolidays($year)); + } + + /** @return array */ + protected function variableHolidays(int $year): array + { + $easter = CarbonImmutable::createFromTimestamp(easter_date($year)) + ->setTimezone('Europe/Rome'); + + return [ + 'Lunedì di Pasqua' => $easter->addDay(1), + ]; + } +} From 97e031aae6dd74cdb8747da60ff9c3490129b426 Mon Sep 17 00:00:00 2001 From: mauricius Date: Wed, 17 Jan 2024 18:02:58 +0100 Subject: [PATCH 2/5] add: italian tests --- .../it_can_calculate_italian_holidays.snap | 46 +++++++++++++++++++ tests/Countries/ItalyTest.php | 18 ++++++++ 2 files changed, 64 insertions(+) create mode 100644 tests/.pest/snapshots/Countries/ItalyTest/it_can_calculate_italian_holidays.snap create mode 100644 tests/Countries/ItalyTest.php diff --git a/tests/.pest/snapshots/Countries/ItalyTest/it_can_calculate_italian_holidays.snap b/tests/.pest/snapshots/Countries/ItalyTest/it_can_calculate_italian_holidays.snap new file mode 100644 index 000000000..b390d06e5 --- /dev/null +++ b/tests/.pest/snapshots/Countries/ItalyTest/it_can_calculate_italian_holidays.snap @@ -0,0 +1,46 @@ +[ + { + "name": "Capodanno", + "date": "2024-01-01" + }, + { + "name": "Epifania", + "date": "2024-01-06" + }, + { + "name": "Luned\u00ec di Pasqua", + "date": "2024-04-01" + }, + { + "name": "Liberazione dal nazifascismo", + "date": "2024-04-25" + }, + { + "name": "Festa del lavoro", + "date": "2024-05-01" + }, + { + "name": "Festa della Repubblica", + "date": "2024-06-02" + }, + { + "name": "Assunzione di Maria", + "date": "2024-08-15" + }, + { + "name": "Ognissanti", + "date": "2024-11-01" + }, + { + "name": "Immacolata Concezione", + "date": "2024-12-08" + }, + { + "name": "Natale di Ges\u00f9", + "date": "2024-12-25" + }, + { + "name": "Santo Stefano", + "date": "2024-12-26" + } +] \ No newline at end of file diff --git a/tests/Countries/ItalyTest.php b/tests/Countries/ItalyTest.php new file mode 100644 index 000000000..bd42933b6 --- /dev/null +++ b/tests/Countries/ItalyTest.php @@ -0,0 +1,18 @@ +get(); + + expect($holidays) + ->toBeArray() + ->not()->toBeEmpty(); + + expect(formatDates($holidays))->toMatchSnapshot(); +}); From a55ac54b07c5f0c4a46c2abe83444ad07d5d2db7 Mon Sep 17 00:00:00 2001 From: mauricius Date: Thu, 18 Jan 2024 14:20:51 +0100 Subject: [PATCH 3/5] remove: phpdoc --- src/Countries/Italy.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Countries/Italy.php b/src/Countries/Italy.php index abfc530ec..d302f94d9 100644 --- a/src/Countries/Italy.php +++ b/src/Countries/Italy.php @@ -11,7 +11,6 @@ public function countryCode(): string return 'it'; } - /** @return array */ protected function allHolidays(int $year): array { return array_merge([ From 5907c73907b96895d953154d658ad916997683ad Mon Sep 17 00:00:00 2001 From: mauricius Date: Thu, 18 Jan 2024 17:43:23 +0100 Subject: [PATCH 4/5] fix: fix phpstan --- src/Countries/Italy.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Countries/Italy.php b/src/Countries/Italy.php index d302f94d9..169533aeb 100644 --- a/src/Countries/Italy.php +++ b/src/Countries/Italy.php @@ -34,7 +34,7 @@ protected function variableHolidays(int $year): array ->setTimezone('Europe/Rome'); return [ - 'Lunedì di Pasqua' => $easter->addDay(1), + 'Lunedì di Pasqua' => $easter->addDay(), ]; } } From 7b61573783187fb54725cdf69a8f8498864f90cb Mon Sep 17 00:00:00 2001 From: Niels Vanpachtenbeke <10651054+Nielsvanpach@users.noreply.github.com> Date: Thu, 18 Jan 2024 19:03:01 +0100 Subject: [PATCH 5/5] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 44af97b77..1e0ecdef1 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ use Spatie\Holidays\Countries\Belgium; $holidays = Holidays::for(Belgium::make())->get(); ``` -Alternatively, you could also pass an ISO code to the `for` method. +Alternatively, you could also pass an [ISO 3166-1](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements) code to the `for` method. ```php use Spatie\Holidays\Holidays;