Skip to content

Commit

Permalink
Added Luxembourg Provider (#205)
Browse files Browse the repository at this point in the history
  • Loading branch information
Arkounay authored Feb 18, 2020
1 parent dfaec2c commit 1127c0d
Show file tree
Hide file tree
Showing 24 changed files with 1,103 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/) and this
- Remembrance Day for Homeland War Victims and Remembrance Day for the Victims of Vukovar and Skabrnja is a new official holiday since 2020 in Croatia. [\#203](https://github.com/azuyalabs/yasumi/pull/203) ([krukru](https://github.com/krukru))

### Added
- Added Luxembourg Provider [\#205](https://github.com/azuyalabs/yasumi/pull/205) ([Arkounay](https://github.com/Arkounay))
- Catalan translations for holidays in Catalonia, Valencian Community, Balearic Islands and Aragon [\#189](https://github.com/azuyalabs/yasumi/pull/189) ([c960657](https://github.com/c960657))
- Added French translation for Second Christmas Day [\#188](https://github.com/azuyalabs/yasumi/pull/188) ([Arkounay](https://github.com/Arkounay))
- Additional Dates for Australia/Victoria:AFL Grand Final Friday [\#190](https://github.com/azuyalabs/yasumi/pull/190) ([brucealdridge](https://github.com/brucealdridge))
Expand Down
103 changes: 103 additions & 0 deletions src/Yasumi/Provider/Luxembourg.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<?php

namespace Yasumi\Provider;

use DateTime;
use DateTimeZone;
use Yasumi\Exception\InvalidDateException;
use Yasumi\Exception\UnknownLocaleException;
use Yasumi\Holiday;

/**
* Provider for all holidays in Luxembourg.
*/
class Luxembourg extends AbstractProvider
{
use CommonHolidays, ChristianHolidays;

public const EUROPE_DAY_START_YEAR = 2019;

/**
* Code to identify this Holiday Provider. Typically this is the ISO3166 code corresponding to the respective
* country or sub-region.
*/
public const ID = 'LU';

/**
* Initialize holidays for Luxembourg.
*
* @throws \Yasumi\Exception\InvalidDateException
* @throws \InvalidArgumentException
* @throws \Yasumi\Exception\UnknownLocaleException
* @throws \Exception
*/
public function initialize(): void
{
$this->timezone = 'Europe/Luxembourg';

// Add common holidays
$this->addHoliday($this->newYearsDay($this->year, $this->timezone, $this->locale));
$this->addHoliday($this->easterMonday($this->year, $this->timezone, $this->locale));
$this->addHoliday($this->internationalWorkersDay($this->year, $this->timezone, $this->locale));
$this->calculateEuropeDay();
$this->addHoliday($this->ascensionDay($this->year, $this->timezone, $this->locale));
$this->addHoliday($this->pentecostMonday($this->year, $this->timezone, $this->locale));
$this->calculateNationalDay();
$this->addHoliday($this->assumptionOfMary($this->year, $this->timezone, $this->locale));
$this->addHoliday($this->allSaintsDay($this->year, $this->timezone, $this->locale));
$this->addHoliday($this->christmasDay($this->year, $this->timezone, $this->locale));
$this->addHoliday($this->secondChristmasDay($this->year, $this->timezone, $this->locale));
}

/**
* Europe Day.
*
* Europe Day is celebrated on 5 May by the Council of Europe and on 9 May by the European Union.
* The first recognition of Europe Day was by the Council of Europe, introduced in 1964.
* The European Union later started to celebrate its own European Day in commemoration of the 1950
* Schuman Declaration, leading it to be referred to by some as "Schuman Day".
* Both days are celebrated by displaying the Flag of Europe.
*
* @link https://en.wikipedia.org/wiki/Europe_Day
*
* @throws InvalidDateException
* @throws \InvalidArgumentException
* @throws UnknownLocaleException
* @throws \Exception
*/
public function calculateEuropeDay(): void
{
if ($this->year >= 2019) {
$this->addHoliday(new Holiday('europeDay', [
'en_US' => 'Europe day',
'fr_FR' => 'La Journée de l\'Europe',
'lu' => 'La Journée de l\'Europe',
], new DateTime("$this->year-5-9", new DateTimeZone($this->timezone)), $this->locale));
}
}

/**
* Luxembourgish National Day.
*
* The Grand Duke's Official Birthday (French: Célébration publique de l'anniversaire du souverain),
* also known as Luxembourgish National Day (French: Fête nationale luxembourgeoise, Luxembourgish:
* Lëtzebuerger Nationalfeierdag), is celebrated as the annual national holiday of Luxembourg.
* It is celebrated on 23 June, although this has never been the actual birthday of any ruler of Luxembourg.
* When the monarch of Luxembourg is female, it is known as the Grand Duchess' Official Birthday.
*
* @link https://en.wikipedia.org/wiki/Grand_Duke%27s_Official_Birthday
*
* @throws InvalidDateException
* @throws \InvalidArgumentException
* @throws UnknownLocaleException
* @throws \Exception
*/
public function calculateNationalDay(): void
{
$this->addHoliday(new Holiday('nationalDay', [
'en_US' => 'National day',
'fr_FR' => 'La Fête nationale',
'lu' => 'La Fête nationale',
], new DateTime("$this->year-6-23", new DateTimeZone($this->timezone)), $this->locale));
}
}
1 change: 1 addition & 0 deletions src/Yasumi/data/translations/allSaintsDay.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
'it' => 'Festa di Tutti i Santi',
'it_CH' => 'Ognissanti',
'lt' => 'Visų šventųjų diena (Vėlinės)',
'lu' => 'Toussaint',
'nl' => 'Allerheiligen',
'pl' => 'Uroczystość Wszystkich Świętych',
'pt' => 'Dia de todos os Santos',
Expand Down
1 change: 1 addition & 0 deletions src/Yasumi/data/translations/ascensionDay.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
'fi' => 'Helatorstai',
'fr' => 'Ascension',
'it' => 'Ascensione',
'lu' => 'Ascension',
'nb' => 'Kristi himmelfartsdag',
'nl' => 'Hemelvaart',
'sv' => 'Kristi himmelsfärdsdag',
Expand Down
1 change: 1 addition & 0 deletions src/Yasumi/data/translations/assumptionOfMary.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
'it' => 'Assunzione di Maria Vergine',
'it_CH' => 'Assunzione',
'lt' => 'Žolinė (Švč. Mergelės Marijos ėmimo į dangų diena)',
'lu' => 'Assomption',
'nl' => 'Onze Lieve Vrouw hemelvaart',
'pl' => 'Wniebowzięcie Najświętszej Marii Panny',
'pt' => 'Assunção de Nossa Senhora',
Expand Down
1 change: 1 addition & 0 deletions src/Yasumi/data/translations/christmasDay.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
'it' => 'Natale',
'ko' => '기독탄신일',
'lt' => 'Šv. Kalėdos',
'lu' => 'Noël',
'lv' => 'Ziemassvētki',
'nb' => 'første juledag',
'nl' => 'eerste kerstdag',
Expand Down
1 change: 1 addition & 0 deletions src/Yasumi/data/translations/easterMonday.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
'it' => 'Lunedì dell’Angelo',
'it_CH' => 'Lunedi di Pasqua',
'lt' => 'Antroji Velykų diena',
'lu' => 'Lundi de Pâques',
'lv' => 'Otrās Lieldienas',
'nb' => 'andre påskedag',
'nl_BE' => 'paasmaandag',
Expand Down
1 change: 1 addition & 0 deletions src/Yasumi/data/translations/internationalWorkersDay.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
'ja' => '労働の日',
'ko' => '노동절',
'lt' => 'Tarptautinė darbo diena',
'lu' => 'Fête du Travail',
'lv' => 'Darba svētki',
'nb' => 'arbeidernes dag',
'nl' => 'Dag van de arbeid',
Expand Down
1 change: 1 addition & 0 deletions src/Yasumi/data/translations/newYearsDay.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
'ja' => '元日',
'ko' => '새해',
'lt' => 'Naujųjų metų diena',
'lu' => 'Jour de l\'An',
'lv' => 'Jaunais Gads',
'nb' => 'første nyttårsdag',
'nl' => 'Nieuwjaar',
Expand Down
7 changes: 4 additions & 3 deletions src/Yasumi/data/translations/pentecostMonday.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@
'ga' => 'Luan Cincíse',
'hu' => 'Pünkösdhétfő',
'it' => 'Lunedi di Pentecoste',
'nb' => 'andre pinsedag',
'nl' => 'tweede pinksterdag',
'nl_BE' => 'pinkstermaandag',
'lu' => 'Lundi de Pentecôte',
'nb' => 'Andre pinsedag',
'nl' => 'Tweede pinksterdag',
'nl_BE' => 'Pinkstermaandag',
'ro' => 'A doua zi de Rusalii',
];
1 change: 1 addition & 0 deletions src/Yasumi/data/translations/secondChristmasDay.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
'hu' => 'Karácsony másnapja',
'ko' => '성탄절 연휴',
'lt' => 'Kalėdos (antra diena)',
'lu' => 'Lendemain de Noël',
'lv' => 'Otrie Ziemassvētki',
'nb' => 'andre juledag',
'nl' => 'tweede kerstdag',
Expand Down
79 changes: 79 additions & 0 deletions tests/Luxembourg/AllSaintsDayTest.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 <[email protected]>
*/

namespace Yasumi\tests\Luxembourg;

use DateTime;
use Exception;
use ReflectionException;
use Yasumi\Holiday;
use Yasumi\tests\YasumiTestCaseInterface;

/**
* Class for testing All Saints' Day in Luxembourg.
*/
class AllSaintsDayTest extends LuxembourgBaseTestCase implements YasumiTestCaseInterface
{
/**
* The name of the holiday
*/
public const HOLIDAY = 'allSaintsDay';

/**
* Tests All Saints' Day.
*
* @dataProvider AllSaintsDayDataProvider
*
* @param int $year the year for which All Saints' Day needs to be tested
* @param DateTime $expected the expected date
*
* @throws ReflectionException
*/
public function testAllSaintsDay($year, $expected)
{
$this->assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
}

/**
* Tests translated name of All Saints' Day.
* @throws ReflectionException
*/
public function testTranslation(): void
{
$this->assertTranslatedHolidayName(
self::REGION,
self::HOLIDAY,
$this->generateRandomYear(),
[self::LOCALE => 'Toussaint']
);
}

/**
* Tests type of the holiday defined in this test.
* @throws ReflectionException
*/
public function testHolidayType(): void
{
$this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(), Holiday::TYPE_OFFICIAL);
}

/**
* Returns a list of random test dates used for assertion of All Saints' Day.
*
* @return array list of test dates for All Saints' Day
* @throws Exception
*/
public function AllSaintsDayDataProvider(): array
{
return $this->generateRandomDates(11, 1, self::TIMEZONE);
}
}
70 changes: 70 additions & 0 deletions tests/Luxembourg/AscensionDayTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?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 <[email protected]>
*/

namespace Yasumi\tests\Luxembourg;

use DateTime;
use DateTimeZone;
use Exception;
use ReflectionException;
use Yasumi\Holiday;
use Yasumi\tests\YasumiTestCaseInterface;

/**
* Class for testing Ascension Day in Luxembourg.
*/
class AscensionDayTest extends LuxembourgBaseTestCase implements YasumiTestCaseInterface
{
/**
* The name of the holiday
*/
public const HOLIDAY = 'ascensionDay';

/**
* Tests Ascension Day.
* @throws Exception
* @throws ReflectionException
*/
public function testAscensionDay()
{
$year = 1901;
$this->assertHoliday(
self::REGION,
self::HOLIDAY,
$year,
new DateTime("$year-5-16", new DateTimeZone(self::TIMEZONE))
);
}

/**
* Tests translated name of Ascension Day.
* @throws ReflectionException
*/
public function testTranslation(): void
{
$this->assertTranslatedHolidayName(
self::REGION,
self::HOLIDAY,
$this->generateRandomYear(),
[self::LOCALE => 'Ascension']
);
}

/**
* Tests type of the holiday defined in this test.
* @throws ReflectionException
*/
public function testHolidayType(): void
{
$this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(), Holiday::TYPE_OFFICIAL);
}
}
Loading

0 comments on commit 1127c0d

Please sign in to comment.