diff --git a/src/Countries/Australia.php b/src/Countries/Australia.php new file mode 100644 index 000000000..a8aa5a4e9 --- /dev/null +++ b/src/Countries/Australia.php @@ -0,0 +1,39 @@ + */ + protected function allHolidays(int $year): array + { + return array_merge([ + 'New Year\'s Day' => '01-01', + 'Australia Day' => '01-26', + 'Anzac Day' => '04-25', + 'Christmas Day' => '12-25', + 'Boxing Day' => '12-26', + ], $this->variableHolidays($year)); + } + + /** @return array */ + protected function variableHolidays(int $year): array + { + $easter = CarbonImmutable::createFromTimestamp(easter_date($year))->setTimezone('Australia/Sydney'); + + return [ + 'Queen\'s Birthday' => CarbonImmutable::parse('second monday of june'), + 'Good Friday' => $easter->subDays(2), + 'Easter Saturday' => $easter->subDay(), + 'Easter Sunday' => $easter, + 'Easter Monday' => $easter->addDay(), + ]; + } +} diff --git a/tests/.pest/snapshots/Countries/AustraliaTest/it_can_calculate_australian_holidays.snap b/tests/.pest/snapshots/Countries/AustraliaTest/it_can_calculate_australian_holidays.snap new file mode 100644 index 000000000..90bf1c708 --- /dev/null +++ b/tests/.pest/snapshots/Countries/AustraliaTest/it_can_calculate_australian_holidays.snap @@ -0,0 +1,42 @@ +[ + { + "name": "New Year's Day", + "date": "2024-01-01" + }, + { + "name": "Australia Day", + "date": "2024-01-26" + }, + { + "name": "Good Friday", + "date": "2024-03-29" + }, + { + "name": "Easter Saturday", + "date": "2024-03-30" + }, + { + "name": "Easter Sunday", + "date": "2024-03-31" + }, + { + "name": "Easter Monday", + "date": "2024-04-01" + }, + { + "name": "Anzac Day", + "date": "2024-04-25" + }, + { + "name": "Queen's Birthday", + "date": "2024-06-10" + }, + { + "name": "Christmas Day", + "date": "2024-12-25" + }, + { + "name": "Boxing Day", + "date": "2024-12-26" + } +] \ No newline at end of file diff --git a/tests/Countries/AustraliaTest.php b/tests/Countries/AustraliaTest.php new file mode 100644 index 000000000..fea311550 --- /dev/null +++ b/tests/Countries/AustraliaTest.php @@ -0,0 +1,18 @@ +get(); + + expect($holidays) + ->toBeArray() + ->not()->toBeEmpty(); + + expect(formatDates($holidays))->toMatchSnapshot(); +});