Skip to content

Commit

Permalink
Holiday providers for states of Austria (#182)
Browse files Browse the repository at this point in the history
* Added holiday providers for states of Austria.
* Implemented tests for holiday providers that belong to states of Austria.
* Added translations for holidays that belong to states of Austria.
  • Loading branch information
aprog authored and stelgenhof committed Nov 9, 2019
1 parent 9044e9f commit 05b1688
Show file tree
Hide file tree
Showing 35 changed files with 1,763 additions and 3 deletions.
30 changes: 30 additions & 0 deletions src/Yasumi/Provider/Austria.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,34 @@ private function calculateNationalDay(): void
$this->locale
));
}

/**
* Saint Leopold's Day.
*
* Saint Leopold III, known as Leopold the Good, was the Margrave of Austria
* from 1095 to his death in 1136. He was a member of the House of
* Babenberg. He was canonized on 6 January 1485 and became the patron saint
* of Austria, Lower Austria, Upper Austria, and Vienna. His feast day is 15
* November.
*
* @link https://en.wikipedia.org/wiki/Leopold_III,_Margrave_of_Austria
*
* @throws InvalidDateException
* @throws \InvalidArgumentException
* @throws UnknownLocaleException
* @throws \Exception
*/
protected function calculateStLeopoldsDay(): void
{
if ($this->year < 1136) {
return;
}

$this->addHoliday(new Holiday(
'stLeopoldsDay',
[],
new DateTime($this->year . '-11-15', new \DateTimeZone($this->timezone)),
$this->locale
));
}
}
47 changes: 47 additions & 0 deletions src/Yasumi/Provider/Austria/Burgenland.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php declare(strict_types=1);
/**
* This file is part of the Yasumi package.
*
* Copyright (c) 2015 - 2019 AzuyaLabs
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @author Sacha Telgenhof <me@sachatelgenhof.com>
*/

namespace Yasumi\Provider\Austria;

use Yasumi\Exception\InvalidDateException;
use Yasumi\Exception\UnknownLocaleException;
use Yasumi\Provider\Austria;

/**
* Provider for all holidays in Burgenland (Austria).
*
* @link https://en.wikipedia.org/wiki/Burgenland
*/
class Burgenland extends Austria
{
/**
* Code to identify this Holiday Provider. Typically this is the ISO3166 code corresponding to the respective
* country or sub-region.
*/
public const ID = 'AT-1';

/**
* Initialize holidays for Burgenland (Austria).
*
* @throws InvalidDateException
* @throws \InvalidArgumentException
* @throws UnknownLocaleException
* @throws \Exception
*/
public function initialize(): void
{
parent::initialize();

// Add custom Common holidays.
$this->addHoliday($this->stMartinsDay($this->year, $this->timezone, $this->locale));
}
}
79 changes: 79 additions & 0 deletions src/Yasumi/Provider/Austria/Carinthia.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?php declare(strict_types=1);
/**
* This file is part of the Yasumi package.
*
* Copyright (c) 2015 - 2019 AzuyaLabs
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @author Sacha Telgenhof <me@sachatelgenhof.com>
*/

namespace Yasumi\Provider\Austria;

use DateTime;
use Yasumi\Exception\InvalidDateException;
use Yasumi\Exception\UnknownLocaleException;
use Yasumi\Holiday;
use Yasumi\Provider\Austria;

/**
* Provider for all holidays in Carinthia (Austria).
*
* @link https://en.wikipedia.org/wiki/Carinthia
*/
class Carinthia extends Austria
{
/**
* Code to identify this Holiday Provider. Typically this is the ISO3166 code corresponding to the respective
* country or sub-region.
*/
public const ID = 'AT-2';

/**
* Initialize holidays for Carinthia (Austria).
*
* @throws InvalidDateException
* @throws \InvalidArgumentException
* @throws UnknownLocaleException
* @throws \Exception
*/
public function initialize(): void
{
parent::initialize();

// Add custom Common holidays.
$this->addHoliday($this->stJosephsDay($this->year, $this->timezone, $this->locale));
$this->calculatePlebisciteDay();
}

/**
* Plebiscite Day.
*
* The Carinthian plebiscite was held on 10 October 1920 in the area
* predominantly settled by Carinthian Slovenes. It determined the final
* southern border between the Republic of Austria and the newly formed
* Kingdom of Serbs, Croats and Slovenes (Yugoslavia) after World War I.
*
* @link https://en.wikipedia.org/wiki/1920_Carinthian_plebiscite
*
* @throws InvalidDateException
* @throws \InvalidArgumentException
* @throws UnknownLocaleException
* @throws \Exception
*/
private function calculatePlebisciteDay(): void
{
if ($this->year < 1920) {
return;
}

$this->addHoliday(new Holiday(
'plebisciteDay',
[],
new DateTime($this->year . '-10-10', new \DateTimeZone($this->timezone)),
$this->locale
));
}
}
47 changes: 47 additions & 0 deletions src/Yasumi/Provider/Austria/LowerAustria.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php declare(strict_types=1);
/**
* This file is part of the Yasumi package.
*
* Copyright (c) 2015 - 2019 AzuyaLabs
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @author Sacha Telgenhof <me@sachatelgenhof.com>
*/

namespace Yasumi\Provider\Austria;

use Yasumi\Exception\InvalidDateException;
use Yasumi\Exception\UnknownLocaleException;
use Yasumi\Provider\Austria;

/**
* Provider for all holidays in Lower Austria (Austria).
*
* @link https://en.wikipedia.org/wiki/Lower_Austria
*/
class LowerAustria extends Austria
{
/**
* Code to identify this Holiday Provider. Typically this is the ISO3166 code corresponding to the respective
* country or sub-region.
*/
public const ID = 'AT-3';

/**
* Initialize holidays for Lower Austria (Austria).
*
* @throws InvalidDateException
* @throws \InvalidArgumentException
* @throws UnknownLocaleException
* @throws \Exception
*/
public function initialize(): void
{
parent::initialize();

// Add custom holidays.
$this->calculateStLeopoldsDay();
}
}
80 changes: 80 additions & 0 deletions src/Yasumi/Provider/Austria/Salzburg.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?php declare(strict_types=1);
/**
* This file is part of the Yasumi package.
*
* Copyright (c) 2015 - 2019 AzuyaLabs
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @author Sacha Telgenhof <me@sachatelgenhof.com>
*/

namespace Yasumi\Provider\Austria;

use DateTime;
use Yasumi\Exception\InvalidDateException;
use Yasumi\Exception\UnknownLocaleException;
use Yasumi\Holiday;
use Yasumi\Provider\Austria;

/**
* Provider for all holidays in Salzburg (Austria).
*
* @link https://en.wikipedia.org/wiki/Salzburg_(state)
*/
class Salzburg extends Austria
{
/**
* Code to identify this Holiday Provider. Typically this is the ISO3166 code corresponding to the respective
* country or sub-region.
*/
public const ID = 'AT-5';

/**
* Initialize holidays for Salzburg (Austria).
*
* @throws InvalidDateException
* @throws \InvalidArgumentException
* @throws UnknownLocaleException
* @throws \Exception
*/
public function initialize(): void
{
parent::initialize();

// Add custom holidays.
$this->calculateStRupertsDay();
}

/**
* Saint Rupert's Day.
*
* Rupert of Salzburg was Bishop of Worms as well as the first Bishop of
* Salzburg and abbot of St. Peter's in Salzburg. He was a contemporary of
* the Frankish king Childebert III and is venerated as a saint in the
* Roman Catholic and Eastern Orthodox Churches. Rupert is also patron
* saint of the Austrian state of Salzburg. His feast day in Austria is
* September 24 (since 710).
*
* @link https://en.wikipedia.org/wiki/Rupert_of_Salzburg
*
* @throws InvalidDateException
* @throws \InvalidArgumentException
* @throws UnknownLocaleException
* @throws \Exception
*/
private function calculateStRupertsDay(): void
{
if ($this->year < 710) {
return;
}

$this->addHoliday(new Holiday(
'stRupertsDay',
[],
new DateTime($this->year . '-9-24', new \DateTimeZone($this->timezone)),
$this->locale
));
}
}
47 changes: 47 additions & 0 deletions src/Yasumi/Provider/Austria/Styria.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php declare(strict_types=1);
/**
* This file is part of the Yasumi package.
*
* Copyright (c) 2015 - 2019 AzuyaLabs
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @author Sacha Telgenhof <me@sachatelgenhof.com>
*/

namespace Yasumi\Provider\Austria;

use Yasumi\Exception\InvalidDateException;
use Yasumi\Exception\UnknownLocaleException;
use Yasumi\Provider\Austria;

/**
* Provider for all holidays in Styria (Austria).
*
* @link https://en.wikipedia.org/wiki/Styria
*/
class Styria extends Austria
{
/**
* Code to identify this Holiday Provider. Typically this is the ISO3166 code corresponding to the respective
* country or sub-region.
*/
public const ID = 'AT-6';

/**
* Initialize holidays for Styria (Austria).
*
* @throws InvalidDateException
* @throws \InvalidArgumentException
* @throws UnknownLocaleException
* @throws \Exception
*/
public function initialize(): void
{
parent::initialize();

// Add custom Common holidays.
$this->addHoliday($this->stJosephsDay($this->year, $this->timezone, $this->locale));
}
}
47 changes: 47 additions & 0 deletions src/Yasumi/Provider/Austria/Tyrol.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php declare(strict_types=1);
/**
* This file is part of the Yasumi package.
*
* Copyright (c) 2015 - 2019 AzuyaLabs
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @author Sacha Telgenhof <me@sachatelgenhof.com>
*/

namespace Yasumi\Provider\Austria;

use Yasumi\Exception\InvalidDateException;
use Yasumi\Exception\UnknownLocaleException;
use Yasumi\Provider\Austria;

/**
* Provider for all holidays in Tyrol (Austria).
*
* @link https://en.wikipedia.org/wiki/Tyrol_(state)
*/
class Tyrol extends Austria
{
/**
* Code to identify this Holiday Provider. Typically this is the ISO3166 code corresponding to the respective
* country or sub-region.
*/
public const ID = 'AT-7';

/**
* Initialize holidays for Tyrol (Austria).
*
* @throws InvalidDateException
* @throws \InvalidArgumentException
* @throws UnknownLocaleException
* @throws \Exception
*/
public function initialize(): void
{
parent::initialize();

// Add custom Common holidays.
$this->addHoliday($this->stJosephsDay($this->year, $this->timezone, $this->locale));
}
}
Loading

0 comments on commit 05b1688

Please sign in to comment.