diff --git a/.editorconfig b/.editorconfig index a7c44ddb1..6f7c0773a 100644 --- a/.editorconfig +++ b/.editorconfig @@ -13,3 +13,6 @@ trim_trailing_whitespace = false [*.{yml,yaml}] indent_size = 2 + +[*.snap] +insert_final_newline = false \ No newline at end of file diff --git a/src/Countries/Nicaragua.php b/src/Countries/Nicaragua.php new file mode 100644 index 000000000..8614270b6 --- /dev/null +++ b/src/Countries/Nicaragua.php @@ -0,0 +1,39 @@ + '01-01', + 'Día internacional de los trabajadores' => '05-01', + 'Día de las madres' => '05-30', + 'Aniversario de la revolución' => '07-19', + 'Aniversario de la batalla de san jacinto' => '09-14', + 'Aniversario de la independencia' => '09-15', + 'Día de la inmaculada concepción' => '12-08', + 'Navidad' => '12-25', + ], $this->variableHolidays($year)); + } + + /** @return array */ + protected function variableHolidays(int $year): array + { + $easter = CarbonImmutable::createFromTimestamp(easter_date($year)) + ->setTimezone('America/Managua'); + + return [ + 'Jueves santo' => $easter->subDays(3), + 'Viernes santo' => $easter->subDays(2), + ]; + } +} diff --git a/tests/.pest/snapshots/Countries/NicaraguaTest/it_can_calculate_nicaragua_holidays.snap b/tests/.pest/snapshots/Countries/NicaraguaTest/it_can_calculate_nicaragua_holidays.snap new file mode 100644 index 000000000..572176fc8 --- /dev/null +++ b/tests/.pest/snapshots/Countries/NicaraguaTest/it_can_calculate_nicaragua_holidays.snap @@ -0,0 +1,42 @@ +[ + { + "name": "A\u00f1o nuevo", + "date": "2024-01-01" + }, + { + "name": "Jueves santo", + "date": "2024-03-27" + }, + { + "name": "Viernes santo", + "date": "2024-03-28" + }, + { + "name": "D\u00eda internacional de los trabajadores", + "date": "2024-05-01" + }, + { + "name": "D\u00eda de las madres", + "date": "2024-05-30" + }, + { + "name": "Aniversario de la revoluci\u00f3n", + "date": "2024-07-19" + }, + { + "name": "Aniversario de la batalla de san jacinto", + "date": "2024-09-14" + }, + { + "name": "Aniversario de la independencia", + "date": "2024-09-15" + }, + { + "name": "D\u00eda de la inmaculada concepci\u00f3n", + "date": "2024-12-08" + }, + { + "name": "Navidad", + "date": "2024-12-25" + } +] \ No newline at end of file diff --git a/tests/Countries/NicaraguaTest.php b/tests/Countries/NicaraguaTest.php new file mode 100644 index 000000000..840a0609a --- /dev/null +++ b/tests/Countries/NicaraguaTest.php @@ -0,0 +1,18 @@ +get(); + + expect($holidays) + ->toBeArray() + ->not()->toBeEmpty(); + + expect(formatDates($holidays))->toMatchSnapshot(); +});