diff --git a/src/Countries/Colombia.php b/src/Countries/Colombia.php new file mode 100644 index 000000000..e2430f76a --- /dev/null +++ b/src/Countries/Colombia.php @@ -0,0 +1,58 @@ + '01-01', + 'Día del Trabajo' => '05-01', + 'Día de la independencia' => '07-20', + 'Batalla de Boyacá' => '08-07', + 'Inmaculada Concepción' => '12-08', + 'Navidad' => '12-25', + ], $this->variableHolidays($year)); + } + + /** @return array */ + protected function variableHolidays(int $year): array + { + $easter = $this->easter($year); + + return [ + 'Jueves Santo' => $easter->subDays(3), + 'Viernes Santo' => $easter->subDays(2), + 'Ascención de Jesús' => $easter->addDays(43), + 'Corpus Christi' => $easter->addDays(64), + 'Sagrado corazón de Jesús' => $easter->addDays(71), + 'Reyes Magos' => $this->emilianiHoliday($year, 1, 6), + 'Día de San José' => $this->emilianiHoliday($year, 3, 19), + 'San Pedro y San Pablo' => $this->emilianiHoliday($year, 6, 29), + 'Asunción de la Virgen' => $this->emilianiHoliday($year, 8, 15), + 'Día de la raza' => $this->emilianiHoliday($year, 10, 12), + 'Todos los santos' => $this->emilianiHoliday($year, 11, 1), + 'Independencia de Cartagena' => $this->emilianiHoliday($year, 11, 11), + + ]; + } + + /** @return CarbonImmutable */ + private function emilianiHoliday(int $year, int $month, int $day): CarbonImmutable + { + $dateObj = CarbonImmutable::createFromDate($year, $month, $day, 'America/Bogota')->startOfDay(); + if ($dateObj->is('Monday')) { + return $dateObj; + } else { + return $dateObj->next('Monday'); + } + } +} diff --git a/tests/.pest/snapshots/Countries/ColombiaTest/it_can_calculate_colombian_holidays.snap b/tests/.pest/snapshots/Countries/ColombiaTest/it_can_calculate_colombian_holidays.snap new file mode 100644 index 000000000..38e611c25 --- /dev/null +++ b/tests/.pest/snapshots/Countries/ColombiaTest/it_can_calculate_colombian_holidays.snap @@ -0,0 +1,74 @@ +[ + { + "name": "A\u00f1o Nuevo", + "date": "2024-01-01" + }, + { + "name": "Reyes Magos", + "date": "2024-01-08" + }, + { + "name": "D\u00eda de San Jos\u00e9", + "date": "2024-03-25" + }, + { + "name": "Jueves Santo", + "date": "2024-03-28" + }, + { + "name": "Viernes Santo", + "date": "2024-03-29" + }, + { + "name": "D\u00eda del Trabajo", + "date": "2024-05-01" + }, + { + "name": "Ascenci\u00f3n de Jes\u00fas", + "date": "2024-05-13" + }, + { + "name": "Corpus Christi", + "date": "2024-06-03" + }, + { + "name": "Sagrado coraz\u00f3n de Jes\u00fas", + "date": "2024-06-10" + }, + { + "name": "San Pedro y San Pablo", + "date": "2024-07-01" + }, + { + "name": "D\u00eda de la independencia", + "date": "2024-07-20" + }, + { + "name": "Batalla de Boyac\u00e1", + "date": "2024-08-07" + }, + { + "name": "Asunci\u00f3n de la Virgen", + "date": "2024-08-19" + }, + { + "name": "D\u00eda de la raza", + "date": "2024-10-14" + }, + { + "name": "Todos los santos", + "date": "2024-11-04" + }, + { + "name": "Independencia de Cartagena", + "date": "2024-11-11" + }, + { + "name": "Inmaculada Concepci\u00f3n", + "date": "2024-12-08" + }, + { + "name": "Navidad", + "date": "2024-12-25" + } +] \ No newline at end of file diff --git a/tests/Countries/ColombiaTest.php b/tests/Countries/ColombiaTest.php new file mode 100644 index 000000000..623ffd94b --- /dev/null +++ b/tests/Countries/ColombiaTest.php @@ -0,0 +1,18 @@ +get(); + + expect($holidays) + ->toBeArray() + ->not()->toBeEmpty(); + + expect(formatDates($holidays))->toMatchSnapshot(); +});