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; diff --git a/src/Countries/Italy.php b/src/Countries/Italy.php new file mode 100644 index 000000000..169533aeb --- /dev/null +++ b/src/Countries/Italy.php @@ -0,0 +1,40 @@ + '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(), + ]; + } +} 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(); +});