diff --git a/src/Countries/Portugal.php b/src/Countries/Portugal.php new file mode 100644 index 000000000..c27489e5c --- /dev/null +++ b/src/Countries/Portugal.php @@ -0,0 +1,42 @@ + '01-01', + 'Dia da Liberdade' => '04-25', + 'Dia do Trabalhador' => '05-01', + 'Dia de Portugal' => '06-10', + 'Assunção da Nossa Senhora' => '08-15', + 'Implantação da República' => '10-05', + 'Dia de Todos os Santos' => '11-01', + 'Restauração da Independência' => '12-01', + 'Imaculada Conceição' => '12-08', + 'Natal' => '12-25' + ], $this->variableHolidays($year)); + } + + /** @return array */ + protected function variableHolidays(int $year): array + { + $easter = CarbonImmutable::createFromTimestamp(easter_date($year)) + ->setTimezone('Europe/Lisbon'); + + return [ + 'Páscoa' => $easter, + 'Sexta-feira Santa' => $easter->subDays(2), + 'Corpo de Deus' => $easter->addDays(60), + ]; + } +} diff --git a/tests/.pest/snapshots/Countries/PortugalTest/it_can_calculate_portuguese_holidays.snap b/tests/.pest/snapshots/Countries/PortugalTest/it_can_calculate_portuguese_holidays.snap new file mode 100644 index 000000000..13513781f --- /dev/null +++ b/tests/.pest/snapshots/Countries/PortugalTest/it_can_calculate_portuguese_holidays.snap @@ -0,0 +1,54 @@ +[ + { + "name": "Dia de Ano Novo", + "date": "2024-01-01" + }, + { + "name": "Sexta-feira Santa", + "date": "2024-03-29" + }, + { + "name": "P\u00e1scoa", + "date": "2024-03-31" + }, + { + "name": "Dia da Liberdade", + "date": "2024-04-25" + }, + { + "name": "Dia do Trabalhador", + "date": "2024-05-01" + }, + { + "name": "Corpo de Deus", + "date": "2024-05-30" + }, + { + "name": "Dia de Portugal", + "date": "2024-06-10" + }, + { + "name": "Assun\u00e7\u00e3o da Nossa Senhora", + "date": "2024-08-15" + }, + { + "name": "Implanta\u00e7\u00e3o da Rep\u00fablica", + "date": "2024-10-05" + }, + { + "name": "Dia de Todos os Santos", + "date": "2024-11-01" + }, + { + "name": "Restaura\u00e7\u00e3o da Independ\u00eancia", + "date": "2024-12-01" + }, + { + "name": "Imaculada Concei\u00e7\u00e3o", + "date": "2024-12-08" + }, + { + "name": "Natal", + "date": "2024-12-25" + } +] \ No newline at end of file diff --git a/tests/Countries/PortugalTest.php b/tests/Countries/PortugalTest.php new file mode 100644 index 000000000..7c2ed381f --- /dev/null +++ b/tests/Countries/PortugalTest.php @@ -0,0 +1,19 @@ +get(); + + expect($holidays) + ->toBeArray() + ->not()->toBeEmpty(); + + expect(formatDates($holidays))->toMatchSnapshot(); + +});