-
-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
43dc736
commit 08382f5
Showing
33 changed files
with
1,679 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,198 @@ | ||
<?php | ||
/** | ||
* This file is part of the Yasumi package. | ||
* | ||
* Copyright (c) 2015 - 2016 AzuyaLabs | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @author Bruce Aldridge <bruce@incode.nz> | ||
*/ | ||
|
||
namespace Yasumi\Provider; | ||
|
||
use DateInterval; | ||
use DateTime; | ||
use DateTimeZone; | ||
use Yasumi\Holiday; | ||
|
||
/** | ||
* Provider for all holidays in Australia. | ||
*/ | ||
class Australia extends AbstractProvider | ||
{ | ||
use CommonHolidays, ChristianHolidays; | ||
|
||
/** | ||
* Code to identify this Holiday Provider. Typically this is the ISO3166 code corresponding to the respective | ||
* country or subregion. | ||
*/ | ||
const ID = 'AU'; | ||
|
||
public $timezone = 'Australia/Melbourne'; | ||
|
||
/** | ||
* Initialize holidays for Australia. | ||
*/ | ||
public function initialize() | ||
{ | ||
|
||
|
||
// National Holidays | ||
$this->calculateAustraliaDay(); | ||
$this->calculateNewYearHolidays(); | ||
$this->calculateAnzacDay(); | ||
//$this->calculateQueensBirthday(); | ||
//$this->calculateLabourDay(); | ||
|
||
// Add Christian holidays | ||
$this->addHoliday($this->goodFriday($this->year, $this->timezone, $this->locale)); | ||
$this->addHoliday($this->easterMonday($this->year, $this->timezone, $this->locale)); | ||
$this->calculateChristmasDay(); | ||
} | ||
|
||
/** | ||
* Australia Day. | ||
* | ||
* Australia Day is the official National Day of Australia. Celebrated annually on 26 January, | ||
* it marks the anniversary of the 1788 arrival of the First Fleet of British Ships at | ||
* Port Jackson, New South Wales, and the raising of the Flag of Great Britain at Sydney Cove | ||
* by Governor Arthur Phillip. In present-day Australia, celebrations reflect the diverse | ||
* society and landscape of the nation, and are marked by community and family events, | ||
* reflections on Australian history, official community awards, and citizenship ceremonies | ||
* welcoming new immigrants into the Australian community. | ||
* | ||
* @link https://en.wikipedia.org/wiki/Waitangi_Day | ||
* @link https://www.timeanddate.com/holidays/australia/australia-day | ||
*/ | ||
public function calculateAustraliaDay() | ||
{ | ||
$date = new DateTime("$this->year-01-26", new DateTimeZone($this->timezone)); | ||
|
||
$this->calculateHoliday('australiaDay', [], $date); | ||
} | ||
|
||
/** | ||
* ANZAC Day. | ||
* | ||
* Anzac Day is a national day of remembrance in Australia and New Zealand that broadly commemorates all Australians | ||
* and New Zealanders "who served and died in all wars, conflicts, and peacekeeping operations" | ||
* Observed on 25 April each year. | ||
* | ||
* @link https://en.wikipedia.org/wiki/Anzac_Day | ||
* @link https://www.timeanddate.com/holidays/australia/anzac-day | ||
*/ | ||
public function calculateAnzacDay() | ||
{ | ||
if ($this->year < 1921) { | ||
return; | ||
} | ||
|
||
$date = new DateTime("$this->year-04-25", new DateTimeZone($this->timezone)); | ||
|
||
$this->calculateHoliday('anzacDay', [], $date, true, true); | ||
} | ||
|
||
/** | ||
* Queens Birthday. | ||
* | ||
* The Queen's Birthday is an Australian public holiday but the date varies across | ||
* states and territories. Australia celebrates this holiday because it is a constitutional | ||
* monarchy, with the English monarch as head of state. | ||
* | ||
* Her actual birthday is on April 21, but it's celebrated as a public holiday on the second Monday of June. | ||
* (Except QLD & WA) | ||
* | ||
* @link https://www.timeanddate.com/holidays/australia/queens-birthday | ||
*/ | ||
public function calculateQueensBirthday() | ||
{ | ||
$this->calculateHoliday( | ||
'queensBirthday', | ||
['en_AU' => 'Queens Birthday'], | ||
'second monday of june '.$this->year, | ||
false, | ||
false | ||
); | ||
} | ||
|
||
/** | ||
* Christmas Day / Boxing Day. | ||
* | ||
* Christmas day, and Boxing day are public holidays in Australia, | ||
* if they fall on the weekend they are moved to the next available weekday. | ||
* | ||
* @link https://www.timeanddate.com/holidays/australia/christmas-day-holiday | ||
*/ | ||
public function calculateChristmasDay() | ||
{ | ||
$christmasDay = new DateTime("$this->year-12-25", new DateTimeZone($this->timezone)); | ||
$boxingDay = new DateTime("$this->year-12-26", new DateTimeZone($this->timezone)); | ||
|
||
switch ($christmasDay->format('w')) { | ||
case 0: // sunday | ||
$christmasDay->add(new \DateInterval('P2D')); | ||
break; | ||
case 5: // friday | ||
$boxingDay->add(new \DateInterval('P2D')); | ||
break; | ||
case 6: // saturday | ||
$christmasDay->add(new \DateInterval('P2D')); | ||
$boxingDay->add(new \DateInterval('P2D')); | ||
break; | ||
} | ||
$this->calculateHoliday('christmasDay', [], $christmasDay); | ||
$this->calculateHoliday('secondChristmasDay', [], $boxingDay); | ||
} | ||
|
||
/** | ||
* Holidays associated with the start of the modern Gregorian calendar. | ||
* | ||
* New Year's Day is on January 1 and is the first day of a new year in the Gregorian calendar, | ||
* which is used in Australia and many other countries. Due to its geographical position close | ||
* to the International Date Line, Australia is one of the first countries in the world to | ||
* welcome the New Year. | ||
* | ||
* @link https://www.timeanddate.com/holidays/australia/new-year-day | ||
*/ | ||
public function calculateNewYearHolidays() | ||
{ | ||
$this->calculateHoliday('newYearsDay', [], new DateTime("$this->year-01-01", new DateTimeZone($this->timezone))); | ||
} | ||
|
||
|
||
/** | ||
* @link https://www.timeanddate.com/holidays/australia/labour-day | ||
*/ | ||
public function calculateLabourDay() | ||
{ | ||
$date = new DateTime('first Monday in October' . " $this->year", | ||
new DateTimeZone($this->timezone)); | ||
|
||
$this->addHoliday(new Holiday('labourDay', [], $date, $this->locale)); | ||
} | ||
|
||
|
||
/** | ||
* Function to simplify moving holidays to mondays if required | ||
* @param $shortName | ||
* @param array $names | ||
* @param $date | ||
* @param bool $moveFromSaturday | ||
* @param bool $moveFromSunday | ||
*/ | ||
public function calculateHoliday($shortName, $names = [], $date, $moveFromSaturday = true, $moveFromSunday = true) | ||
{ | ||
$holidayDate = $date instanceof DateTime ? $date : new DateTime($date, new DateTimeZone($this->timezone)); | ||
|
||
$day = $holidayDate->format('w'); | ||
//echo ' - '.$shortName.' - Day: '.$day."\n"; | ||
if (($day == 0 && $moveFromSunday) || ($day == 6 && $moveFromSaturday)) { | ||
//echo ' - '.$shortName.' - Need to move: '.($day == 0 ? '1 day' : '2days')."\n"; | ||
$holidayDate->add($day == 0 ? new DateInterval('P1D') : new DateInterval('P2D')); | ||
} | ||
|
||
$this->addHoliday(new Holiday($shortName, $names, $holidayDate, $this->locale)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<?php | ||
/** | ||
* This file is part of the Yasumi package. | ||
* | ||
* Copyright (c) 2015 - 2016 AzuyaLabs | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @author Bruce Aldridge <bruce@incode.nz> | ||
*/ | ||
|
||
namespace Yasumi\Provider\Australia; | ||
|
||
use DateTime; | ||
use DateTimeZone; | ||
use Yasumi\Holiday; | ||
use Yasumi\Provider\Australia; | ||
|
||
/** | ||
* Provider for all holidays in Victoria (Australia). | ||
* | ||
*/ | ||
class Victoria extends Australia | ||
{ | ||
/** | ||
* Code to identify this Holiday Provider. Typically this is the ISO3166 code corresponding to the respective | ||
* country or subregion. | ||
*/ | ||
const ID = 'AU-VIC'; | ||
|
||
/** | ||
* Initialize holidays for Victoria (Australia). | ||
*/ | ||
public function initialize() | ||
{ | ||
parent::initialize(); | ||
|
||
$this->calculateLabourDay(); | ||
$this->calculateQueensBirthday(); | ||
$this->calculateMelbourneCupDay(); | ||
$this->calculateAFLGrandFinalDay(); | ||
} | ||
|
||
public function calculateChristmasDay() | ||
{ | ||
$christmasDay = new DateTime("$this->year-12-25", new DateTimeZone($this->timezone)); | ||
$boxingDay = new DateTime("$this->year-12-26", new DateTimeZone($this->timezone)); | ||
|
||
$this->calculateHoliday('christmasDay', [], $christmasDay); | ||
$this->calculateHoliday('secondChristmasDay', [], $boxingDay, false, true); | ||
} | ||
|
||
public function calculateLabourDay() | ||
{ | ||
$date = new DateTime("second monday of march $this->year", | ||
new DateTimeZone($this->timezone)); | ||
|
||
$this->addHoliday(new Holiday('labourDay', [], $date, $this->locale)); | ||
} | ||
public function calculateMelbourneCupDay() | ||
{ | ||
$date = new DateTime('first Tuesday of November' . " $this->year", | ||
new DateTimeZone($this->timezone)); | ||
|
||
$this->addHoliday(new Holiday('melbourneCup', ['en_AU' => 'Melbourne Cup'], $date, $this->locale)); | ||
} | ||
|
||
public function calculateAFLGrandFinalDay() | ||
{ | ||
switch ($this->year) { | ||
case 2015: | ||
$aflGrandFinalFriday = '2015-10-02'; | ||
break; | ||
case 2016: | ||
$aflGrandFinalFriday = '2016-09-30'; | ||
break; | ||
default: | ||
return; | ||
} | ||
|
||
$date = new DateTime($aflGrandFinalFriday, | ||
new DateTimeZone($this->timezone)); | ||
|
||
$this->addHoliday(new Holiday('aflGrandFinalFriday', ['en_AU' => 'AFL Grand Final Friday'], $date, $this->locale)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
/** | ||
* This file is part of the Yasumi package. | ||
* | ||
* Copyright (c) 2015 - 2016 AzuyaLabs | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @author Sacha Telgenhof <stelgenhof@gmail.com> | ||
*/ | ||
|
||
// Translation for Australia Day | ||
return [ | ||
'en_AU' => 'Australia Day', | ||
'en_US' => 'Australia Day', | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.