diff --git a/src/Countries/Canada.php b/src/Countries/Canada.php new file mode 100644 index 000000000..309f3d4f8 --- /dev/null +++ b/src/Countries/Canada.php @@ -0,0 +1,38 @@ + '01-01', + 'Canada Day' => '07-05', + 'Christmas Day' => '12-25', + ], $this->variableHolidays($year)); + } + + /** @return array */ + protected function variableHolidays(int $year): array + { + $labourDay = new CarbonImmutable("first monday of september {$year}"); + + $easter = $this->easter($year); + + return [ + 'Good Friday' => $easter->subDays(2), + 'Labour Day' => $labourDay, + ]; + } +} diff --git a/tests/.pest/snapshots/Countries/CanadaTest/it_can_calculate_canadian_holidays.snap b/tests/.pest/snapshots/Countries/CanadaTest/it_can_calculate_canadian_holidays.snap new file mode 100644 index 000000000..7ef6e1c83 --- /dev/null +++ b/tests/.pest/snapshots/Countries/CanadaTest/it_can_calculate_canadian_holidays.snap @@ -0,0 +1,22 @@ +[ + { + "name": "New Year's Day", + "date": "2024-01-01" + }, + { + "name": "Good Friday", + "date": "2024-03-29" + }, + { + "name": "Canada Day", + "date": "2024-07-05" + }, + { + "name": "Labour Day", + "date": "2024-09-02" + }, + { + "name": "Christmas Day", + "date": "2024-12-25" + } +] \ No newline at end of file diff --git a/tests/Countries/CanadaTest.php b/tests/Countries/CanadaTest.php new file mode 100644 index 000000000..45ac7be51 --- /dev/null +++ b/tests/Countries/CanadaTest.php @@ -0,0 +1,19 @@ +get(); + + expect($holidays) + ->toBeArray() + ->not()->toBeEmpty(); + + expect(formatDates($holidays))->toMatchSnapshot(); + +});