diff --git a/src/Countries/Indonesia.php b/src/Countries/Indonesia.php new file mode 100644 index 000000000..5ce415c22 --- /dev/null +++ b/src/Countries/Indonesia.php @@ -0,0 +1,38 @@ + */ + protected function allHolidays(int $year): array + { + return array_merge([ + 'Tahun Baru' => '01-01', + 'Hari Buruh Internasional' => '05-01', + 'Hari Lahir Pancasila' => '06-01', + 'Hari Kemerdekaan' => '08-17', + 'Hari Raya Natal' => '12-25', + ], $this->variableHolidays($year)); + } + + /** @return array */ + protected function variableHolidays(int $year): array + { + $easter = CarbonImmutable::createFromTimestamp(easter_date($year)) + ->setTimezone('Asia/Jakarta'); + + return [ + 'Jumat Agung' => $easter->subDays(2), + 'Hari Paskah' => $easter, + 'Kenaikan Yesus Kristus' => $easter->addDays(39), + ]; + } +} \ No newline at end of file diff --git a/tests/.pest/snapshots/Countries/IndonesiaTest/it_can_calculate_indonesia_holidays.snap b/tests/.pest/snapshots/Countries/IndonesiaTest/it_can_calculate_indonesia_holidays.snap new file mode 100644 index 000000000..1a24b0c6e --- /dev/null +++ b/tests/.pest/snapshots/Countries/IndonesiaTest/it_can_calculate_indonesia_holidays.snap @@ -0,0 +1,34 @@ +[ + { + "name": "Tahun Baru", + "date": "2024-01-01" + }, + { + "name": "Jumat Agung", + "date": "2024-03-29" + }, + { + "name": "Hari Paskah", + "date": "2024-03-31" + }, + { + "name": "Hari Buruh Internasional", + "date": "2024-05-01" + }, + { + "name": "Kenaikan Yesus Kristus", + "date": "2024-05-09" + }, + { + "name": "Hari Lahir Pancasila", + "date": "2024-06-01" + }, + { + "name": "Hari Kemerdekaan", + "date": "2024-08-17" + }, + { + "name": "Hari Raya Natal", + "date": "2024-12-25" + }, +] \ No newline at end of file diff --git a/tests/Countries/IndonesiaTest.php b/tests/Countries/IndonesiaTest.php new file mode 100644 index 000000000..b62931cc9 --- /dev/null +++ b/tests/Countries/IndonesiaTest.php @@ -0,0 +1,18 @@ +get(); + + expect($holidays) + ->toBeArray() + ->not()->toBeEmpty(); + + expect(formatDates($holidays))->toMatchSnapshot(); +}); \ No newline at end of file