-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from umulmrum/feature/latvia
Feature/latvia
- Loading branch information
Showing
10 changed files
with
155 additions
and
2 deletions.
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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,81 @@ | ||
<?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\Latvia; | ||
|
||
use Umulmrum\Holiday\Compensatory\CompensatoryDaysCalculator; | ||
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\CompensatoryHolidayProviderInterface; | ||
use Umulmrum\Holiday\Provider\Religion\ChristianHolidaysTrait; | ||
|
||
use function array_filter; | ||
|
||
class Latvia implements CompensatoryHolidayProviderInterface | ||
{ | ||
use ChristianHolidaysTrait; | ||
use CommonHolidaysTrait; | ||
|
||
public function calculateHolidaysForYear(int $year): HolidayList | ||
{ | ||
return new HolidayList(array_filter([ | ||
$this->getNewYear($year, HolidayType::DAY_OFF), | ||
$this->getGoodFriday($year, HolidayType::OFFICIAL | HolidayType::DAY_OFF | HolidayType::PARTIAL_ONLY), | ||
$this->getEasterMonday($year, HolidayType::OFFICIAL | HolidayType::DAY_OFF), | ||
$this->getLaborDay($year, HolidayType::DAY_OFF), | ||
$this->getRestorationOfIndependenceDay($year, HolidayType::DAY_OFF), | ||
$this->getMidsummersEve($year, HolidayType::DAY_OFF), | ||
$this->getMidsummersDay($year, HolidayType::DAY_OFF), | ||
$this->getProclamationDay($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), | ||
$this->getNewYearsEve($year, HolidayType::OFFICIAL | HolidayType::DAY_OFF), | ||
])); | ||
} | ||
|
||
protected function getRestorationOfIndependenceDay(int $year, int $additionalType = HolidayType::OTHER): ?Holiday | ||
{ | ||
return $year >= 1990 | ||
? Holiday::create(HolidayName::RESTORATION_OF_INDEPENDENCE_DAY, "{$year}-05-04", HolidayType::OFFICIAL | $additionalType) | ||
: null; | ||
} | ||
|
||
protected function getMidsummersEve(int $year, int $additionalType = HolidayType::OTHER): Holiday | ||
{ | ||
return Holiday::create(HolidayName::MIDSUMMER_EVE, "{$year}-06-23", HolidayType::OFFICIAL | $additionalType); | ||
} | ||
|
||
protected function getMidsummersDay(int $year, int $additionalType = HolidayType::OTHER): Holiday | ||
{ | ||
return Holiday::create(HolidayName::MIDSUMMERS_DAY, "{$year}-06-24", HolidayType::OFFICIAL | $additionalType); | ||
} | ||
|
||
protected function getProclamationDay(int $year, int $additionalType = HolidayType::OTHER): Holiday | ||
{ | ||
return Holiday::create(HolidayName::PROCLAMATION_DAY_OF_THE_REPUBLIC_OF_LATVIA, "{$year}-11-18", HolidayType::OFFICIAL | $additionalType); | ||
} | ||
|
||
public function getCompensatoryDaysCalculators(int $year): array | ||
{ | ||
return [ | ||
new CompensatoryDaysCalculator( | ||
[ | ||
HolidayName::RESTORATION_OF_INDEPENDENCE_DAY, | ||
HolidayName::PROCLAMATION_DAY_OF_THE_REPUBLIC_OF_LATVIA, | ||
], | ||
), | ||
]; | ||
} | ||
} |
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,52 @@ | ||
# 1989 | ||
|
||
| Date | Name | Types | | ||
|------------|---------------------------------------------------------|--------------------------------------------| | ||
| 1989-01-01 | new_year | official, day_off | | ||
| 1989-03-24 | good_friday | official, day_off, religious, partial_only | | ||
| 1989-03-27 | easter_monday | official, day_off, religious | | ||
| 1989-05-01 | labor_day | official, day_off | | ||
| 1989-06-23 | midsummer_eve | official, day_off | | ||
| 1989-06-24 | midsummers_day | official, day_off | | ||
| 1989-11-18 | proclamation_day_of_the_republic_of_latvia | official, day_off | | ||
| 1989-11-20 | proclamation_day_of_the_republic_of_latvia_compensatory | official, day_off, compensatory | | ||
| 1989-12-24 | christmas_eve | day_off, religious, partial_only | | ||
| 1989-12-25 | christmas_day | official, day_off, religious | | ||
| 1989-12-26 | second_christmas_day | official, day_off, religious | | ||
| 1989-12-31 | new_years_eve | official, day_off | | ||
|
||
# 1990 | ||
|
||
| Date | Name | Types | | ||
|------------|---------------------------------------------------------|--------------------------------------------| | ||
| 1990-01-01 | new_year | official, day_off | | ||
| 1990-04-13 | good_friday | official, day_off, religious, partial_only | | ||
| 1990-04-16 | easter_monday | official, day_off, religious | | ||
| 1990-05-01 | labor_day | official, day_off | | ||
| 1990-05-04 | restoration_of_independence_day | official, day_off | | ||
| 1990-06-23 | midsummer_eve | official, day_off | | ||
| 1990-06-24 | midsummers_day | official, day_off | | ||
| 1990-11-18 | proclamation_day_of_the_republic_of_latvia | official, day_off | | ||
| 1990-11-19 | proclamation_day_of_the_republic_of_latvia_compensatory | official, day_off, compensatory | | ||
| 1990-12-24 | christmas_eve | day_off, religious, partial_only | | ||
| 1990-12-25 | christmas_day | official, day_off, religious | | ||
| 1990-12-26 | second_christmas_day | official, day_off, religious | | ||
| 1990-12-31 | new_years_eve | official, day_off | | ||
|
||
# 2024 | ||
|
||
| Date | Name | Types | | ||
|------------|----------------------------------------------|--------------------------------------------| | ||
| 2024-01-01 | new_year | official, day_off | | ||
| 2024-03-29 | good_friday | official, day_off, religious, partial_only | | ||
| 2024-04-01 | easter_monday | official, day_off, religious | | ||
| 2024-05-01 | labor_day | official, day_off | | ||
| 2024-05-04 | restoration_of_independence_day | official, day_off | | ||
| 2024-05-06 | restoration_of_independence_day_compensatory | official, day_off, compensatory | | ||
| 2024-06-23 | midsummer_eve | official, day_off | | ||
| 2024-06-24 | midsummers_day | official, day_off | | ||
| 2024-11-18 | proclamation_day_of_the_republic_of_latvia | official, day_off | | ||
| 2024-12-24 | christmas_eve | day_off, religious, partial_only | | ||
| 2024-12-25 | christmas_day | official, day_off, religious | | ||
| 2024-12-26 | second_christmas_day | official, day_off, religious | | ||
| 2024-12-31 | new_years_eve | official, day_off | |
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