Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

polish holidays & translation #18

Merged
merged 5 commits into from
Apr 14, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Currently the following holiday providers are implemented:
* Germany
* Greece
* New Zealand
* Poland

Yasumi has the following filters to allow you to filter only certain type of holidays:

Expand Down Expand Up @@ -116,6 +117,7 @@ The tests are organized in some test suites to make testing a bit more easier:
* Germany : For separately testing the Germany Holiday Provider
* Greece : For separately testing the Greece Holiday Provider
* New Zealand : For separately testing the New Zealand Holiday Provider
* Poland : For separately testing the Poland Holiday Provider


Basic Usage
Expand Down Expand Up @@ -245,4 +247,4 @@ Information Sources

- [Wikipedia](https://en.wikipedia.org/wiki/Main_Page)
- [Timeanddate.com](http://www.timeanddate.com/)
- [CLDR - Unicode Common Locale Data Repository](http://cldr.unicode.org/)
- [CLDR - Unicode Common Locale Data Repository](http://cldr.unicode.org/)
78 changes: 78 additions & 0 deletions src/Yasumi/Provider/Poland.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?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>
*/

namespace Yasumi\Provider;

use DateTime;
use DateTimeZone;
use Yasumi\Holiday;

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

/**
* Initialize holidays for Poland.
*/
public function initialize()
{
$this->timezone = 'Europe/Warsaw';

// Add common holidays
$this->addHoliday($this->newYearsDay($this->year, $this->timezone, $this->locale));
$this->addHoliday($this->internationalWorkersDay($this->year, $this->timezone, $this->locale));

// Add Christian holidays
$this->addHoliday($this->allSaintsDay($this->year, $this->timezone, $this->locale));
$this->addHoliday($this->assumptionOfMary($this->year, $this->timezone, $this->locale));
$this->addHoliday($this->christmasDay($this->year, $this->timezone, $this->locale));
$this->addHoliday($this->corpusChristi($this->year, $this->timezone, $this->locale));
$this->addHoliday($this->easter($this->year, $this->timezone, $this->locale));
$this->addHoliday($this->easterMonday($this->year, $this->timezone, $this->locale));
$this->addHoliday($this->epiphany($this->year, $this->timezone, $this->locale));
$this->addHoliday($this->pentecost($this->year, $this->timezone, $this->locale));
$this->addHoliday($this->secondChristmasDay($this->year, $this->timezone, $this->locale));

// Add other holidays
$this->calculateIndependenceDay();
$this->calculateConstitutionDay();
}

/*
* Constitution Day
*
* @link https://en.wikipedia.org/wiki/May_3rd_Constitution_Day
*/
public function calculateConstitutionDay()
{
if ($this->year >= 1791) {
$this->addHoliday(new Holiday('constitutionDay', ['pl_PL' => 'Święto Narodowe Trzeciego Maja'],
new DateTime("$this->year-5-3", new DateTimeZone($this->timezone)), $this->locale));
}
}

/*
* Independence Day
*
* @link https://en.wikipedia.org/wiki/National_Independence_Day_(Poland)
*/
public function calculateIndependenceDay()
{
if ($this->year >= 1918) {
$this->addHoliday(new Holiday('independenceDay', ['pl_PL' => 'Narodowe Święto Niepodległości'],
new DateTime("$this->year-11-11", 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 @@ -21,5 +21,6 @@
'it_IT' => 'Festa di Tutti i Santi',
'nl_BE' => 'Allerheiligen',
'nl_NL' => 'Allerheiligen',
'pl_PL' => 'Uroczystość Wszystkich Świętych',
'sv_SE' => 'alla helgons dag',
];
1 change: 1 addition & 0 deletions src/Yasumi/data/translations/assumptionOfMary.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@
'it_IT' => 'Assunzione di Maria Vergine',
'nl_BE' => 'Onze Lieve Vrouw hemelvaart',
'nl_NL' => 'Onze Lieve Vrouw hemelvaart',
'pl_PL' => 'Wniebowzięcie Najświętszej Marii Panny',
];
1 change: 1 addition & 0 deletions src/Yasumi/data/translations/christmasDay.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@
'nb_NO' => 'Første juledag',
'nl_BE' => 'Kerstmis',
'nl_NL' => 'Kerstmis',
'pl_PL' => 'pierwszy dzień Bożego Narodzenia',
'sv_SE' => 'juldagen',
];
1 change: 1 addition & 0 deletions src/Yasumi/data/translations/corpusChristi.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@
'de_DE' => 'Fronleichnam',
'en_US' => 'Corpus Christi',
'es_ES' => 'Corpus Christi',
'pl_PL' => 'Boże Ciało',
];
1 change: 1 addition & 0 deletions src/Yasumi/data/translations/easter.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@
'nb_NO' => 'Første påskedag',
'nl_BE' => 'Eerste Paasdag',
'nl_NL' => 'Eerste Paasdag',
'pl_PL' => 'Wielkanoc',
'sv_SE' => 'påskdagen',
];
1 change: 1 addition & 0 deletions src/Yasumi/data/translations/easterMonday.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@
'nb_NO' => 'Andre påskedag',
'nl_BE' => 'Paasmaandag',
'nl_NL' => 'Tweede Paasdag',
'pl_PL' => 'Poniedziałek Wielkanocny',
'sv_SE' => 'annandag påsk',
];
2 changes: 1 addition & 1 deletion src/Yasumi/data/translations/goodFriday.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
'nb_NO' => 'Langfredag',
'nl_BE' => 'Goede Vrijdag',
'nl_NL' => 'Goede Vrijdag',
'pl_PL' => 'Dobry Piątek',
'pl_PL' => 'Wielki Piątek',
'sv_SE' => 'långfredagen',
];
1 change: 1 addition & 0 deletions src/Yasumi/data/translations/internationalWorkersDay.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@
'nb_NO' => 'Arbeidernes dag',
'nl_BE' => 'Dag van de arbeid',
'nl_NL' => 'Dag van de arbeid',
'pl_PL' => 'Święto Pracy',
'sv_SE' => 'Första maj',
];
1 change: 1 addition & 0 deletions src/Yasumi/data/translations/pentecost.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@
'nb_NO' => 'Første pinsedag',
'nl_BE' => 'Eerste Pinksterdag',
'nl_NL' => 'Eerste Pinksterdag',
'pl_PL' => 'Zielone Świątki',
'sv_SE' => 'Pingstdagen',
];
1 change: 1 addition & 0 deletions src/Yasumi/data/translations/secondChristmasDay.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@
'nb_NO' => 'Andre juledag',
'nl_BE' => 'Tweede Kerstdag',
'nl_NL' => 'Tweede Kerstdag',
'pl_PL' => 'drugi dzień Bożego Narodzenia',
'sv_SE' => 'annandag jul',
];
58 changes: 58 additions & 0 deletions tests/Poland/AllSaintsDayTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?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>
*/

namespace Yasumi\tests\Poland;

use DateTime;

/**
* Class for testing All Saints' Day in Poland.
*/
class AllSaintsDayTest extends PolandBaseTestCase
{
/**
* The name of the holiday to be tested
*/
const HOLIDAY = 'allSaintsDay';

/**
* Tests the holiday defined in this test.
*
* @dataProvider HolidayDataProvider
*
* @param int $year the year for which the holiday defined in this test needs to be tested
* @param DateTime $expected the expected date
*/
public function testHoliday($year, $expected)
{
$this->assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
}

/**
* Returns a list of random test dates used for assertion of the holiday defined in this test
*
* @return array list of test dates for the holiday defined in this test
*/
public function HolidayDataProvider()
{
return $this->generateRandomDates(11, 1, self::TIMEZONE);
}

/**
* Tests the translated name of the holiday defined in this test.
*/
public function testTranslation()
{
$this->assertTranslatedHolidayName(self::REGION, self::HOLIDAY, $this->generateRandomYear(),
['pl_PL' => 'Uroczystość Wszystkich Świętych']);
}
}
58 changes: 58 additions & 0 deletions tests/Poland/AssumptionOfMaryTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?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>
*/

namespace Yasumi\tests\Poland;

use DateTime;

/**
* Class for testing the day of the Assumption of Mary in Poland.
*/
class AssumptionOfMaryTest extends PolandBaseTestCase
{
/**
* The name of the holiday to be tested
*/
const HOLIDAY = 'assumptionOfMary';

/**
* Tests the holiday defined in this test.
*
* @dataProvider HolidayDataProvider
*
* @param int $year the year for which the holiday defined in this test needs to be tested
* @param DateTime $expected the expected date
*/
public function testHoliday($year, $expected)
{
$this->assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
}

/**
* Returns a list of random test dates used for assertion of the holiday defined in this test.
*
* @return array list of test dates for the day of the holiday defined in this test
*/
public function HolidayDataProvider()
{
return $this->generateRandomDates(8, 15, self::TIMEZONE);
}

/**
* Tests the translated name of the holiday defined in this test.
*/
public function testTranslation()
{
$this->assertTranslatedHolidayName(self::REGION, self::HOLIDAY, $this->generateRandomYear(),
['pl_PL' => 'Wniebowzięcie Najświętszej Marii Panny']);
}
}
58 changes: 58 additions & 0 deletions tests/Poland/ChristmasTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?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>
*/

namespace Yasumi\tests\Poland;

use DateTime;

/**
* Class for testing Christmas in Poland.
*/
class ChristmasTest extends PolandBaseTestCase
{
/**
* The name of the holiday
*/
const HOLIDAY = 'christmasDay';

/**
* Tests Christmas Day.
*
* @dataProvider ChristmasDayDataProvider
*
* @param int $year the year for which Christmas Day needs to be tested
* @param DateTime $expected the expected date
*/
public function testChristmasDay($year, $expected)
{
$this->assertHoliday(self::REGION, self::HOLIDAY, $year, $expected);
}

/**
* Returns a list of random test dates used for assertion of Christmas Day.
*
* @return array list of test dates for Christmas Day
*/
public function ChristmasDayDataProvider()
{
return $this->generateRandomDates(12, 25, self::TIMEZONE);
}

/**
* Tests translated name of Christmas Day.
*/
public function testTranslation()
{
$this->assertTranslatedHolidayName(self::REGION, self::HOLIDAY, $this->generateRandomYear(),
['pl_PL' => 'pierwszy dzień Bożego Narodzenia']);
}
}
Loading