Skip to content

Commit

Permalink
Add state regional holidays
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickomeara committed Jan 22, 2024
1 parent cb241b9 commit c243974
Show file tree
Hide file tree
Showing 7 changed files with 376 additions and 1 deletion.
84 changes: 84 additions & 0 deletions src/Countries/Australia.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@

class Australia extends Country
{
protected function __construct(
protected ?string $region = null,
) {
}

public function countryCode(): string
{
return 'au';
Expand All @@ -30,6 +35,85 @@ protected function variableHolidays(int $year): array
return [
'Good Friday' => $easter->subDays(2),
'Easter Monday' => $easter->addDay(),
// https://en.wikipedia.org/wiki/Public_holidays_in_Australia
...array_filter(match($this->region) {
'act' => [
'Canberra Day' => CarbonImmutable::parse("second monday of march {$year}"),
'Easter Saturday' => $easter->subDay(),
'Easter Sunday' => $easter,
'Reconciliation Day' => CarbonImmutable::parse("first monday after or on 27 may {$year}"),
'King\'s Birthday' => $year >= 2023 ? CarbonImmutable::parse("second monday of june {$year}") : null,
'Queen\'s Birthday' => $year < 2023 ? CarbonImmutable::parse("second monday of june {$year}") : null,
'Labour Day' => CarbonImmutable::parse("first monday of october {$year}"),
],
'nsw' => [
'Easter Saturday' => $easter->subDay(),
'Easter Sunday' => $easter,
'King\'s Birthday' => $year >= 2023 ? CarbonImmutable::parse("second monday of june {$year}") : null,
'Queen\'s Birthday' => $year < 2023 ? CarbonImmutable::parse("second monday of june {$year}") : null,
'Labour Day' => CarbonImmutable::parse("first monday of october {$year}"),
],
'nt' => [
'Easter Saturday' => $easter->subDay(),
'May Day' => CarbonImmutable::parse("first monday of may {$year}"),
'Picnic Day' => CarbonImmutable::parse("first monday of august {$year}"),
],
'qld' => [
'The day after Good Friday' => $easter->subDay(),
'Easter Sunday' => $easter,
'Labour Day' => CarbonImmutable::parse("first monday of may {$year}"),
'King\'s Birthday' => $year >= 2023 ? CarbonImmutable::parse("first monday of october {$year}") : null,
'Queen\'s Birthday' => $year < 2023 ? CarbonImmutable::parse("first monday of october {$year}") : null,
],
'sa' => [
'Adelaide Cup Day' => $year < 2006
? CarbonImmutable::parse("third monday of may {$year}")
: CarbonImmutable::parse("second monday of march {$year}"),
'The day after Good Friday' => $easter->subDay(),
'King\'s Birthday' => $year >= 2023 ? CarbonImmutable::parse("second monday of june {$year}") : null,
'Queen\'s Birthday' => $year < 2023 ? CarbonImmutable::parse("second monday of june {$year}") : null,
'Labour Day' => CarbonImmutable::parse("first monday of october {$year}"),
],
'tas' => [
'Eight Hours Day' => CarbonImmutable::parse("second monday of march {$year}"),
'King\'s Birthday' => $year >= 2023 ? CarbonImmutable::parse("second monday of june {$year}") : null,
'Queen\'s Birthday' => $year < 2023 ? CarbonImmutable::parse("second monday of june {$year}") : null,
],
'vic' => [
'Labour Day' => CarbonImmutable::parse("second monday of march {$year}"),
'Saturday before Easter Sunday' => $easter->subDay(),
'Easter Sunday' => $easter,
'King\'s Birthday' => $year >= 2023 ? CarbonImmutable::parse("second monday of june {$year}") : null,
'Queen\'s Birthday' => $year < 2023 ? CarbonImmutable::parse("second monday of june {$year}") : null,
'Friday before AFL Grand Final' => $this->fridayBeforeAflGrandFinal($year),
'Melbourne Cup' => CarbonImmutable::parse("first tuesday of november {$year}"),
],
'wa' => [
'Labour Day' => CarbonImmutable::parse("first monday of march {$year}"),
'Easter Sunday' => $easter,
'Western Australia Day' => CarbonImmutable::parse("first monday of june {$year}"),
// https://www.abc.net.au/news/2022-09-22/queens-birthday-public-holiday-becomes-kings-birthday/101453408
'King\'s Birthday' => $year >= 2022 ? CarbonImmutable::parse("last monday of september {$year}") : null,
'Queen\'s Birthday' => $year < 2022 ? CarbonImmutable::parse("last monday of september {$year}") : null,
],
default => [],
}),
];
}

// https://business.vic.gov.au/business-information/public-holidays/victorian-public-holidays-2025
// https://en.wikipedia.org/wiki/List_of_VFL/AFL_premiers#VFL/AFL_premierships
protected function fridayBeforeAflGrandFinal(int $year): ?CarbonImmutable
{
if ($year < 2015) {
return null;
}

return match ($year) {
2015 => CarbonImmutable::parse('2015-10-02'),
2020 => CarbonImmutable::parse('2020-10-23'),
2022 => CarbonImmutable::parse('2022-09-23'),
default => CarbonImmutable::parse("last friday of september {$year}"),
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
[
{
"name": "New Year's Day",
"date": "2021-01-01"
},
{
"name": "Australia Day",
"date": "2021-01-26"
},
{
"name": "Labour Day",
"date": "2021-03-08"
},
{
"name": "Good Friday",
"date": "2021-04-02"
},
{
"name": "Saturday before Easter Sunday",
"date": "2021-04-03"
},
{
"name": "Easter Sunday",
"date": "2021-04-04"
},
{
"name": "Easter Monday",
"date": "2021-04-05"
},
{
"name": "Anzac Day",
"date": "2021-04-25"
},
{
"name": "Queen's Birthday",
"date": "2021-06-14"
},
{
"name": "Friday before AFL Grand Final",
"date": "2021-09-24"
},
{
"name": "Melbourne Cup",
"date": "2021-11-02"
},
{
"name": "Christmas Day",
"date": "2021-12-25"
},
{
"name": "Boxing Day",
"date": "2021-12-26"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
[
{
"name": "New Year's Day",
"date": "2020-01-01"
},
{
"name": "Australia Day",
"date": "2020-01-26"
},
{
"name": "Labour Day",
"date": "2020-03-09"
},
{
"name": "Good Friday",
"date": "2020-04-10"
},
{
"name": "Saturday before Easter Sunday",
"date": "2020-04-11"
},
{
"name": "Easter Sunday",
"date": "2020-04-12"
},
{
"name": "Easter Monday",
"date": "2020-04-13"
},
{
"name": "Anzac Day",
"date": "2020-04-25"
},
{
"name": "Queen's Birthday",
"date": "2020-06-08"
},
{
"name": "Friday before AFL Grand Final",
"date": "2020-10-23"
},
{
"name": "Melbourne Cup",
"date": "2020-11-03"
},
{
"name": "Christmas Day",
"date": "2020-12-25"
},
{
"name": "Boxing Day",
"date": "2020-12-26"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
[
{
"name": "New Year's Day",
"date": "2014-01-01"
},
{
"name": "Australia Day",
"date": "2014-01-26"
},
{
"name": "Labour Day",
"date": "2014-03-10"
},
{
"name": "Good Friday",
"date": "2014-04-18"
},
{
"name": "Saturday before Easter Sunday",
"date": "2014-04-19"
},
{
"name": "Easter Sunday",
"date": "2014-04-20"
},
{
"name": "Easter Monday",
"date": "2014-04-21"
},
{
"name": "Anzac Day",
"date": "2014-04-25"
},
{
"name": "Queen's Birthday",
"date": "2014-06-09"
},
{
"name": "Melbourne Cup",
"date": "2014-11-04"
},
{
"name": "Christmas Day",
"date": "2014-12-25"
},
{
"name": "Boxing Day",
"date": "2014-12-26"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[
{
"name": "New Year's Day",
"date": "2022-01-01"
},
{
"name": "Australia Day",
"date": "2022-01-26"
},
{
"name": "Labour Day",
"date": "2022-03-07"
},
{
"name": "Good Friday",
"date": "2022-04-15"
},
{
"name": "Easter Sunday",
"date": "2022-04-17"
},
{
"name": "Easter Monday",
"date": "2022-04-18"
},
{
"name": "Anzac Day",
"date": "2022-04-25"
},
{
"name": "Western Australia Day",
"date": "2022-06-06"
},
{
"name": "King's Birthday",
"date": "2022-09-26"
},
{
"name": "Christmas Day",
"date": "2022-12-25"
},
{
"name": "Boxing Day",
"date": "2022-12-26"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[
{
"name": "New Year's Day",
"date": "2021-01-01"
},
{
"name": "Australia Day",
"date": "2021-01-26"
},
{
"name": "Labour Day",
"date": "2021-03-01"
},
{
"name": "Good Friday",
"date": "2021-04-02"
},
{
"name": "Easter Sunday",
"date": "2021-04-04"
},
{
"name": "Easter Monday",
"date": "2021-04-05"
},
{
"name": "Anzac Day",
"date": "2021-04-25"
},
{
"name": "Western Australia Day",
"date": "2021-06-07"
},
{
"name": "Queen's Birthday",
"date": "2021-09-27"
},
{
"name": "Christmas Day",
"date": "2021-12-25"
},
{
"name": "Boxing Day",
"date": "2021-12-26"
}
]
Loading

0 comments on commit c243974

Please sign in to comment.