Skip to content

Commit

Permalink
Holiday Provider for Lithuania (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukosius authored and stelgenhof committed Oct 17, 2017
1 parent ccbd9fe commit 847c9ae
Show file tree
Hide file tree
Showing 28 changed files with 1,313 additions and 0 deletions.
5 changes: 5 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@
<directory suffix="Test.php">./tests/Japan</directory>
</testsuite>

<!-- Test Suite for holidays in Lithuania -->
<testsuite name="Lithuania">
<directory suffix="Test.php">./tests/Lithuania</directory>
</testsuite>

<!-- Test Suite for holidays in Netherlands -->
<testsuite name="Netherlands">
<directory suffix="Test.php">./tests/Netherlands</directory>
Expand Down
131 changes: 131 additions & 0 deletions src/Yasumi/Provider/Lithuania.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
<?php

/**
* This file is part of the Yasumi package.
*
* Copyright (c) 2015 - 2017 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>
*/

namespace Yasumi\Provider;

use Yasumi\Holiday;

/**
* Provider for all holidays in Lithuania.
*
* @author Gedas Lukošius <gedas@lukosius.me>
*/
class Lithuania extends AbstractProvider
{
use CommonHolidays, ChristianHolidays;

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

/**
* The year when The Act of Reinstating Independence of Lithuania was signed.
*/
const RESTORATION_OF_THE_STATE_YEAR = 1918;

/**
* The year when The Act of the Re-Establishment of the State of Lithuania was signed.
*/
const RESTORATION_OF_INDEPENDENCE_YEAR = 1990;

/**
* A year when Mindaugas was crowned as the only King of Lithuania.
*/
const STATEHOOD_YEAR = 1253;

/**
* Initialize holidays for Lithuania.
*
* @throws \InvalidArgumentException
*/
public function initialize()
{
$this->timezone = 'Europe/Vilnius';

// Official
$this->addHoliday($this->newYearsDay($this->year, $this->timezone, $this->locale));
$this->addRestorationOfTheStateDay();
$this->addRestorationOfIndependenceDay();
$this->addHoliday($this->easter($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->addHoliday($this->stJohnsDay($this->year, $this->timezone, $this->locale));
$this->addStatehoodDay();
$this->addHoliday($this->assumptionOfMary($this->year, $this->timezone, $this->locale));
$this->addHoliday($this->allSaintsDay($this->year, $this->timezone, $this->locale));
$this->addHoliday($this->christmasEve($this->year, $this->timezone, $this->locale, Holiday::TYPE_OFFICIAL));
$this->addHoliday($this->christmasDay($this->year, $this->timezone, $this->locale));
$this->addHoliday($this->secondChristmasDay($this->year, $this->timezone, $this->locale));
}

/**
* The Act of Reinstating Independence of Lithuania was signed on February 16, 1918.
*
* @throws \InvalidArgumentException
*/
private function addRestorationOfTheStateDay()
{
if ($this->year >= self::RESTORATION_OF_THE_STATE_YEAR) {
$this->addHoliday(new Holiday(
'restorationOfTheStateOfLithuaniaDay',
[
'en_US' => 'Day of Restoration of the State of Lithuania',
'lt_LT' => 'Lietuvos valstybės atkūrimo diena'
],
new \DateTime("{$this->year}-02-16", new \DateTimeZone($this->timezone))
));
}
}

/**
* The Act of the Re-Establishment of the State of Lithuania was signed on March 11, 1990.
*
* @throws \InvalidArgumentException
*/
private function addRestorationOfIndependenceDay()
{
if ($this->year >= self::RESTORATION_OF_INDEPENDENCE_YEAR) {
$this->addHoliday(new Holiday(
'restorationOfIndependenceOfLithuaniaDay',
[
'en_US' => 'Day of Restoration of Independence of Lithuania',
'lt_LT' => 'Lietuvos nepriklausomybės atkūrimo diena'
],
new \DateTime("{$this->year}-03-11", new \DateTimeZone($this->timezone))
));
}
}

/**
* Statehood Day is an annual public holiday in Lithuania celebrated on July 6 to commemorate
* the coronation in 1253 of Mindaugas as the only King of Lithuania.
*
* @throws \InvalidArgumentException
*/
private function addStatehoodDay()
{
if ($this->year >= self::STATEHOOD_YEAR) {
$this->addHoliday(new Holiday(
'statehoodDay',
[
'en_US' => 'Statehood Day (Lithuania)',
'lt_LT' => 'Valstybės (Lietuvos karaliaus Mindaugo karūnavimo) diena'
],
new \DateTime("{$this->year}-07-06", 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 @@ -25,6 +25,7 @@
'hu_HU' => 'Mindenszentek',
'it_CH' => 'Ognissanti',
'it_IT' => 'Festa di Tutti i Santi',
'lt_LT' => 'Visų šventųjų diena (Vėlinės)',
'nl_BE' => 'Allerheiligen',
'nl_NL' => 'Allerheiligen',
'pl_PL' => 'Uroczystość Wszystkich Świętych',
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 @@
'hr_HR' => 'Velika Gospa',
'it_CH' => 'Assunzione',
'it_IT' => 'Assunzione di Maria Vergine',
'lt_LT' => 'Žolinė (Švč. Mergelės Marijos ėmimo į dangų diena)',
'nl_BE' => 'Onze Lieve Vrouw hemelvaart',
'nl_NL' => 'Onze Lieve Vrouw hemelvaart',
'pl_PL' => 'Wniebowzięcie Najświętszej Marii Panny',
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 @@ -32,6 +32,7 @@
'hu_HU' => 'Karácsony',
'it_CH' => 'Natale',
'it_IT' => 'Natale',
'lt_LT' => 'Šv. Kalėdos',
'nb_NO' => 'Første juledag',
'nl_BE' => 'Kerstmis',
'nl_NL' => 'Kerstmis',
Expand Down
1 change: 1 addition & 0 deletions src/Yasumi/data/translations/christmasEve.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
'en_US' => 'Christmas Eve',
'fr_CH' => 'Réveillon de Noël',
'it_CH' => 'Vigilia di Natale',
'lt_LT' => 'Šv. Kūčios',
'pt_PT' => 'Véspera de Natal',
'ro_RO' => 'Ajunul Crãciunului',
'sk_SK' => 'Štedrý deň',
Expand Down
1 change: 1 addition & 0 deletions src/Yasumi/data/translations/easter.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
'hu_HU' => 'Húsvét',
'it_CH' => 'Pasqua',
'it_IT' => 'Pasqua',
'lt_LT' => 'Velykos',
'nb_NO' => 'Første påskedag',
'nl_BE' => 'Eerste Paasdag',
'nl_NL' => 'Eerste Paasdag',
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 @@ -33,6 +33,7 @@
'hu_HU' => 'Húsvéthétfő',
'it_CH' => 'Lunedi di Pasqua',
'it_IT' => 'Lunedi` dell\'Angelo',
'lt_LT' => 'Antroji Velykų diena',
'nb_NO' => 'Andre påskedag',
'nl_BE' => 'Paasmaandag',
'nl_NL' => 'Tweede Paasdag',
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 @@ -28,6 +28,7 @@
'it_CH' => 'Festa dei lavoratori',
'it_IT' => 'Festa del Lavoro',
'ja_JP' => '労働の日',
'lt_LT' => 'Tarptautinė darbo diena',
'nb_NO' => 'Arbeidernes dag',
'nl_BE' => 'Dag van de arbeid',
'nl_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 @@ -35,6 +35,7 @@
'it_CH' => 'Capodanno',
'it_IT' => 'Capodanno',
'ja_JP' => '元日',
'lt_LT' => 'Naujųjų metų diena',
'nb_NO' => 'Første nyttårsdag',
'nl_BE' => 'Nieuwjaar',
'nl_NL' => 'Nieuwjaar',
Expand Down
1 change: 1 addition & 0 deletions src/Yasumi/data/translations/secondChristmasDay.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
'en_ZA' => 'Day of Goodwill',
'fi_FI' => '2. joulupäivä',
'hu_HU' => 'Karácsony másnapja',
'lt_LT' => 'Kalėdos (antra diena)',
'nb_NO' => 'Andre juledag',
'nl_BE' => 'Tweede Kerstdag',
'nl_NL' => 'Tweede Kerstdag',
Expand Down
1 change: 1 addition & 0 deletions src/Yasumi/data/translations/stJohnsDay.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
'en_US' => 'St. John\'s Day',
'es_ES' => 'Sant Joan',
'fi_FI' => 'Juhannuspäivä',
'lt_LT' => 'Rasos ir Joninių diena',
'sv_SE' => 'midsommardagen',
];
70 changes: 70 additions & 0 deletions tests/Lithuania/AllSaintsDayTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php

/**
* This file is part of the Yasumi package.
*
* Copyright (c) 2015 - 2017 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>
*/

namespace Yasumi\tests\Lithuania;

use Yasumi\Holiday;
use Yasumi\tests\YasumiTestCaseInterface;

/**
* Class containing tests for All Saints' Day in Lithuania.
*
* @author Gedas Lukošius <gedas@lukosius.me>
*/
class AllSaintsDayTest extends LithuaniaBaseTestCase implements YasumiTestCaseInterface
{
/**
* The name of the holiday to be tested
*/
const HOLIDAY = 'allSaintsDay';

/**
* @return array
*/
public function holidayDataProvider()
{
return $this->generateRandomDates(11, 1, self::TIMEZONE);
}

/**
* @dataProvider holidayDataProvider
*
* @param int $year
* @param \DateTime $expected
*/
public function testHoliday($year, \DateTime $expected)
{
$this->assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
}

/**
* {@inheritdoc}
*/
public function testTranslation()
{
$this->assertTranslatedHolidayName(
self::REGION,
self::HOLIDAY,
$this->generateRandomYear(),
[self::LOCALE => 'Visų šventųjų diena (Vėlinės)']
);
}

/**
* {@inheritdoc}
*/
public function testHolidayType()
{
$this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(), Holiday::TYPE_OFFICIAL);
}
}
70 changes: 70 additions & 0 deletions tests/Lithuania/AssumptionOfMaryDayTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php

/**
* This file is part of the Yasumi package.
*
* Copyright (c) 2015 - 2017 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>
*/

namespace Yasumi\tests\Lithuania;

use Yasumi\Holiday;
use Yasumi\tests\YasumiTestCaseInterface;

/**
* Class containing tests for Assumption of Mary day in Lithuania.
*
* @author Gedas Lukošius <gedas@lukosius.me>
*/
class AssumptionOfMaryDayTest extends LithuaniaBaseTestCase implements YasumiTestCaseInterface
{
/**
* The name of the holiday to be tested
*/
const HOLIDAY = 'assumptionOfMary';

/**
* @return array
*/
public function holidayDataProvider()
{
return $this->generateRandomDates(8, 15, self::TIMEZONE);
}

/**
* @dataProvider holidayDataProvider
*
* @param int $year
* @param \DateTime $expected
*/
public function testHoliday($year, \DateTime $expected)
{
$this->assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
}

/**
* {@inheritdoc}
*/
public function testTranslation()
{
$this->assertTranslatedHolidayName(
self::REGION,
self::HOLIDAY,
$this->generateRandomYear(),
[self::LOCALE => 'Žolinė (Švč. Mergelės Marijos ėmimo į dangų diena)']
);
}

/**
* {@inheritdoc}
*/
public function testHolidayType()
{
$this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(), Holiday::TYPE_OFFICIAL);
}
}
Loading

0 comments on commit 847c9ae

Please sign in to comment.