-
-
Notifications
You must be signed in to change notification settings - Fork 150
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
Added support for Germany #9
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ba24298
Added support for Germany
eaglefsd beba7dd
Added local holidays according to http://www.schulferien.org/Feiertag…
eaglefsd 7243ca1
Revert "Added local holidays according to http://www.schulferien.org/…
eaglefsd e3a33b0
Revert "Revert "Added local holidays according to http://www.schulfer…
eaglefsd 106dc21
Removed state holidays
eaglefsd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,97 @@ | ||
<?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 Germany. | ||
*/ | ||
class Germany extends AbstractProvider | ||
{ | ||
use CommonHolidays, ChristianHolidays; | ||
|
||
/** | ||
* Initialize holidays for Germany. | ||
*/ | ||
public function initialize() | ||
{ | ||
$this->timezone = 'Europe/Berlin'; | ||
|
||
// Add common holidays | ||
$this->addHoliday($this->newYearsDay($this->year, $this->timezone, $this->locale)); | ||
|
||
// Add common Christian holidays (common in Germany) | ||
$this->addHoliday($this->ascensionDay($this->year, $this->timezone, $this->locale)); | ||
$this->addHoliday($this->christmasDay($this->year, $this->timezone, $this->locale)); | ||
$this->addHoliday($this->easterMonday($this->year, $this->timezone, $this->locale)); | ||
$this->addHoliday($this->goodFriday($this->year, $this->timezone, $this->locale)); | ||
$this->addHoliday($this->internationalWorkersDay($this->year, $this->timezone, $this->locale)); | ||
$this->addHoliday($this->newYearsDay($this->year, $this->timezone, $this->locale)); | ||
$this->addHoliday($this->pentecostMonday($this->year, $this->timezone, $this->locale)); | ||
$this->addHoliday($this->secondChristmasDay($this->year, $this->timezone, $this->locale)); | ||
|
||
// Calculate other holidays | ||
$this->calculateGermanUnityDay(); | ||
$this->calculateReformationDay(); | ||
} | ||
|
||
/** | ||
* German Unity Day | ||
* | ||
* The Day of German Unity (German: Tag der Deutschen Einheit) is the national day of Germany, celebrated on | ||
* 3 October as a public holiday. It commemorates the anniversary of German reunification in 1990, when the | ||
* goal of a united Germany that originated in the middle of the 19th century, was fulfilled again. Therefore, | ||
* the name addresses neither the re-union nor the union, but the unity of Germany. The Day of German Unity on | ||
* 3 October has been the German national holiday since 1990, when the reunification was formally completed. It | ||
* is a legal holiday for the Federal Republic of Germany. | ||
* | ||
* @link https://en.wikipedia.org/wiki/German_Unity_Day | ||
*/ | ||
public function calculateGermanUnityDay() | ||
{ | ||
if ($this->year >= 1990) { | ||
$this->addHoliday(new Holiday('germanUnityDay', ['de_DE' => 'Tag der Deutschen Einheit'], | ||
new DateTime($this->year . '-10-3', new \DateTimeZone($this->timezone)), $this->locale)); | ||
} | ||
} | ||
|
||
/** | ||
* Calculates the day of the reformation. | ||
* | ||
* Reformation Day is a religious holiday celebrated on October 31, alongside All Hallows' Eve, in remembrance | ||
* of the Reformation. It is celebrated among various Protestants, especially by Lutheran and Reformed church | ||
* communities. | ||
|
||
* It is a civic holiday in the German states of Brandenburg, Mecklenburg-Vorpommern, Saxony, Saxony-Anhalt and | ||
* Thuringia. Slovenia celebrates it as well due to the profound contribution of the Reformation to that nation's | ||
* cultural development, although Slovenes are mainly Roman Catholics. With the increasing influence of | ||
* Protestantism in Latin America (particularly newer groups such as various Evangelical Protestants, Pentecostals | ||
* or Charismatics), it has been declared a national holiday in Chile in 2009. | ||
* | ||
* @link https://en.wikipedia.org/wiki/Reformation_Day | ||
*/ | ||
public function calculateReformationDay() | ||
{ | ||
/** | ||
* @link https://de.wikipedia.org/wiki/Reformationstag#Ursprung_und_Geschichte | ||
*/ | ||
if ($this->year == 2017) { | ||
$this->addHoliday(new Holiday('reformationDay', [ | ||
'de_DE' => 'Reformationstag', | ||
], new DateTime("$this->year-10-31", new DateTimeZone($this->timezone)), $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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?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\Germany; | ||
|
||
use DateTime; | ||
use DateTimeZone; | ||
|
||
/** | ||
* Class for testing Ascension Day in Germany. | ||
*/ | ||
class AscensionDayTest extends GermanyBaseTestCase | ||
{ | ||
/** | ||
* The name of the holiday to be tested | ||
*/ | ||
const HOLIDAY = 'ascensionDay'; | ||
|
||
/** | ||
* Tests Ascension Day. | ||
*/ | ||
public function testAscensionDay() | ||
{ | ||
$year = 1754; | ||
$this->assertHoliday(self::REGION, 'ascensionDay', $year, | ||
new DateTime("$year-5-23", new DateTimeZone(self::TIMEZONE))); | ||
} | ||
|
||
/** | ||
* Tests the translated name of the holiday defined in this test. | ||
*/ | ||
public function testTranslation() | ||
{ | ||
$this->assertTranslatedHolidayName(self::REGION, self::HOLIDAY, $this->generateRandomYear(), | ||
[self::LOCALE => 'Christi Himmelfahrt']); | ||
} | ||
} |
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,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\Germany; | ||
|
||
use DateTime; | ||
|
||
/** | ||
* Class for testing Christmas in Germany. | ||
*/ | ||
class ChristmasTest extends GermanyBaseTestCase | ||
{ | ||
/** | ||
* 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(), | ||
[self::LOCALE => '1. Weihnachtsfeiertag']); | ||
} | ||
} |
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,46 @@ | ||
<?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\Germany; | ||
|
||
use DateTime; | ||
use DateTimeZone; | ||
|
||
/** | ||
* Class containing tests for Easter Monday in Germany. | ||
*/ | ||
class EasterMondayTest extends GermanyBaseTestCase | ||
{ | ||
/** | ||
* The name of the holiday to be tested | ||
*/ | ||
const HOLIDAY = 'easterMonday'; | ||
|
||
/** | ||
* Tests the holiday defined in this test. | ||
*/ | ||
public function testHoliday() | ||
{ | ||
$year = 2000; | ||
$this->assertHoliday(self::REGION, self::HOLIDAY, $year, | ||
new DateTime("$year-4-24", new DateTimeZone(self::TIMEZONE))); | ||
} | ||
|
||
/** | ||
* Tests translated name of the holiday defined in this test. | ||
*/ | ||
public function testTranslation() | ||
{ | ||
$this->assertTranslatedHolidayName(self::REGION, self::HOLIDAY, $this->generateRandomYear(), | ||
[self::LOCALE => 'Ostermontag']); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is Good Friday an official holiday, i.e. offices/shops are closed?