Skip to content

Commit

Permalink
Merge pull request #47 from umulmrum/feature/estonia
Browse files Browse the repository at this point in the history
Add holidays for Estonia
  • Loading branch information
umulmrum authored Jun 10, 2024
2 parents af9fdce + 4dd6be0 commit dbd2d62
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]

### Added
- Holidays for Estonia
- Compensatory days can now be calculated automatically (providers only provide configuration). See the section on adding
a new country or region in README.md for details.

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ Currently only the Gregorian calendar is supported, for years < 10000.
- Canada
- Czech Republic
- Denmark
- Estonia
- Finland
- France (incl. Bas-Rhin, French Guiana, Guadeloupe, Haut-Rhin, Martinique, Moselle, Reunion)
- Germany (incl. Baden-Wuerttemberg, Bavaria, Berlin, Brandenburg, Bremen, Hamburg, Hesse, Lower Saxony, Mecklenburg-Vorpommern, North-rhine Westphalia, Rhineland Palatinate, Saarland, Saxony, Saxony-Anhalt, Schleswig-Holstein, Thuringia)
Expand Down
2 changes: 1 addition & 1 deletion doc/world.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions res/trans/umulmrum_holiday.de.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@
'electoral_day_round_one' => 'Wahltag (Runde 1)',
'electoral_day_round_two' => 'Wahltag (Runde 2)',
'epiphany' => 'Heilige drei Könige',
'estonia_independence_day' => 'Unabhängigkeitstag',
'estonia_victory_day' => 'Siegestag',
'europe_day' => 'Europatag',
'family_day' => 'Tag der Familie',
'fat_tuesday' => 'Faschingsdienstag',
Expand Down Expand Up @@ -121,6 +123,7 @@
'independence_day' => 'Unabhängigkeitstag',
'independence_day_compensatory' => 'Unabhängigkeitstag (Ausgleich)',
'independent_czechoslovak_day' => 'Tag der Entstehung eines selbstständigen tschechoslowakischen Staates',
'independence_restoration_day' => 'Tag der Wiedererlangung der Unabhängigkeit',
'international_holocaust_remembrance_day' => 'Internationaler Tag des Gedenkens an die Opfer des Holocaust',
'international_womens_day' => 'Internationaler Frauentag',
'international_childrens_day' => 'Internationaler Kindertag',
Expand Down Expand Up @@ -214,6 +217,7 @@
'spring_and_labour_day' => 'Tag des Frühlings und der Arbeit',
'spring_and_labour_day_compensatory' => 'Tag des Frühlings und der Arbeit (Ausgleich)',
'spring_bank_holiday' => 'Spring Bank Holiday',
'spring_day' => 'Maifeiertag',
'state_funeral_of_queen_elizabeth' => 'Staatsbegräbnis von Queen Elizabeth II',
'statehood_day' => 'Tag der Tschechischen Staatlichkeit',
'sterling_crisis' => 'Sterling-Krise',
Expand Down
4 changes: 4 additions & 0 deletions res/trans/umulmrum_holiday.en.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@
'electoral_day_round_one' => 'Electoral Day (round 1)',
'electoral_day_round_two' => 'Electoral Day (round 2)',
'epiphany' => 'Epiphany',
'estonia_independence_day' => 'Independence Day',
'estonia_victory_day' => 'Victory Day',
'europe_day' => 'Europe Day',
'family_day' => 'Family Day',
'fat_tuesday' => 'Fat Tuesday',
Expand Down Expand Up @@ -120,6 +122,7 @@
'immaculate_conception' => 'Immaculate Conception',
'independence_day' => 'Independence Day',
'independence_day_compensatory' => 'Independence Day (compensatory)',
'independence_restoration_day' => 'Independence Restoration Day',
'independent_czechoslovak_day' => 'Independent Czechoslovak State Day',
'international_holocaust_remembrance_day' => 'International Holocaust Remembrance Day',
'international_womens_day' => 'International Women\'s Day',
Expand Down Expand Up @@ -213,6 +216,7 @@
'spanish_national_day' => 'Spanish National Day',
'spring_and_labour_day' => 'Spring and Labour Day',
'spring_bank_holiday' => 'Spring Bank Holiday',
'spring_day' => 'Spring Day',
'state_funeral_of_queen_elizabeth' => 'State Funeral of Queen Elizabeth II',
'statehood_day' => 'Statehood Day',
'sterling_crisis' => 'Sterling crisis',
Expand Down
6 changes: 6 additions & 0 deletions src/Constant/HolidayName.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@ final class HolidayName
public const DANISH_NATIONAL_HOLIDAY = 'danish_national_holiday';
public const GENERAL_PRAYER_DAY = 'general_prayer_day';

// Estonia
public const ESTONIA_INDEPENDENCE_DAY = 'estonia_independence_day';
public const ESTONIA_VICTORY_DAY = 'estonia_victory_day';
public const INDEPENDENCE_RESTORATION_DAY = 'independence_restoration_day';
public const SPRING_DAY = 'spring_day';

// Finland
public const FINLAND_INDEPENDENCE_DAY = 'finland_independence_day';

Expand Down
73 changes: 73 additions & 0 deletions src/Provider/Estonia/Estonia.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php

/*
* This file is part of the umulmrum/holiday package.
*
* (c) Stefan Kruppa
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Umulmrum\Holiday\Provider\Estonia;

use Umulmrum\Holiday\Constant\HolidayName;
use Umulmrum\Holiday\Constant\HolidayType;
use Umulmrum\Holiday\Model\Holiday;
use Umulmrum\Holiday\Model\HolidayList;
use Umulmrum\Holiday\Provider\CommonHolidaysTrait;
use Umulmrum\Holiday\Provider\HolidayProviderInterface;
use Umulmrum\Holiday\Provider\Religion\ChristianHolidaysTrait;

use function array_filter;

class Estonia implements HolidayProviderInterface
{
use ChristianHolidaysTrait;
use CommonHolidaysTrait;

public function calculateHolidaysForYear(int $year): HolidayList
{
return new HolidayList(array_filter([
$this->getNewYear($year, HolidayType::DAY_OFF),
$this->getIndependenceDay($year, HolidayType::DAY_OFF),
$this->getGoodFriday($year, HolidayType::OFFICIAL | HolidayType::DAY_OFF | HolidayType::PARTIAL_ONLY),
$this->getEasterSunday($year, HolidayType::OFFICIAL | HolidayType::DAY_OFF),
$this->getSpringDay($year, HolidayType::DAY_OFF),
$this->getWhitSunday($year, HolidayType::OFFICIAL | HolidayType::DAY_OFF),
$this->getVictoryDay($year, HolidayType::DAY_OFF),
$this->getMidsummersDay($year, HolidayType::DAY_OFF),
$this->getIndependenceRestorationDay($year, HolidayType::DAY_OFF),
$this->getChristmasEve($year, HolidayType::DAY_OFF | HolidayType::PARTIAL_ONLY),
$this->getChristmasDay($year, HolidayType::OFFICIAL | HolidayType::DAY_OFF),
$this->getSecondChristmasDay($year, HolidayType::OFFICIAL | HolidayType::DAY_OFF),
]));
}

protected function getMidsummersDay(int $year, int $additionalType = HolidayType::OTHER): Holiday
{
return Holiday::create(HolidayName::MIDSUMMERS_DAY, "{$year}-06-24", HolidayType::OFFICIAL | $additionalType);
}

protected function getIndependenceDay(int $year, int $additionalType = HolidayType::OTHER): Holiday
{
return Holiday::create(HolidayName::ESTONIA_INDEPENDENCE_DAY, "{$year}-02-24", HolidayType::OFFICIAL | $additionalType);
}

protected function getSpringDay(int $year, int $additionalType = HolidayType::OTHER): Holiday
{
return Holiday::create(HolidayName::SPRING_DAY, "{$year}-05-01", HolidayType::OFFICIAL | $additionalType);
}

protected function getVictoryDay(int $year, int $additionalType = HolidayType::OTHER): ?Holiday
{
return Holiday::create(HolidayName::ESTONIA_VICTORY_DAY, "{$year}-06-23", HolidayType::OFFICIAL | $additionalType);
}

protected function getIndependenceRestorationDay(int $year, int $additionalType = HolidayType::OTHER): ?Holiday
{
return $year >= 1998
? Holiday::create(HolidayName::INDEPENDENCE_RESTORATION_DAY, "{$year}-08-20", HolidayType::OFFICIAL | $additionalType)
: null;
}
}
3 changes: 3 additions & 0 deletions src/Resolver/isoData.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@
// Denmark
'DK' => \Umulmrum\Holiday\Provider\Denmark\Denmark::class,

// Estonia
'EE' => \Umulmrum\Holiday\Provider\Estonia\Estonia::class,

// Finland
'FI' => \Umulmrum\Holiday\Provider\Finland\Finland::class,

Expand Down
1 change: 1 addition & 0 deletions tests/regenerateTests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ tests/console test:generate IS -y 2024 -y 2025
tests/console test:generate IE -y 1870 -y 1902 -y 1974 -y 2011 -y 2019 -y 2020
tests/console test:generate IT -y 1911 -y 1945 -y 1946 -y 1950 -y 1961 -y 1977 -y 1985 -y 2001 -y 2011 -y 2020
tests/console test:generate IT-32 -y 2020
tests/console test:generate EE -y 1997 -y 1998 -y 2024
tests/console test:generate FL -y 2020
tests/console test:generate LU -y 1961 -y 2018 -y 2020
tests/console test:generate MX -y 1825 -y 1826 -y 1911 -y 1918 -y 1923 -y 2006 -y 2010 -y 2020 -y 2021 -y 2022 -y 2021,2022
Expand Down

0 comments on commit dbd2d62

Please sign in to comment.