From b92a42bd314ae245f6d3f4db5187497020b7f60e Mon Sep 17 00:00:00 2001 From: SashoRistevski Date: Tue, 18 Jul 2023 12:05:11 +0200 Subject: [PATCH] Added NorthMacedonia Public Holidays --- docs/northmacedonia.md | 13 +++ src/CarbonMacrosServiceProvider.php | 4 + src/Traits/NorthMacedonianDates.php | 79 +++++++++++++++++ tests/NorthMacedonianHolidaysTest.php | 120 ++++++++++++++++++++++++++ 4 files changed, 216 insertions(+) create mode 100644 docs/northmacedonia.md create mode 100644 src/Traits/NorthMacedonianDates.php create mode 100644 tests/NorthMacedonianHolidaysTest.php diff --git a/docs/northmacedonia.md b/docs/northmacedonia.md new file mode 100644 index 0000000..32f3f06 --- /dev/null +++ b/docs/northmacedonia.md @@ -0,0 +1,13 @@ +### North Macedonian dates + +- `isOrthodoxChristmasEve +- `isOrthodoxChristmasDay +- `isDayOffForOrthodoxChristmasDay +- `isOrthodoxEpiphany +- `isNorthMacedonianLaborDay +- `isNorthMacedonianRepublicDay +- `isFeastOfTheAssumptionOfMaryOrthodox +- `isNorthMacedonianIndependenceDay +- `isNorthMacedonianDayOfPeoplesUprising +- `isDayOfTheMacedonianRevolutionaryStruggle +- `isNorthMacedonianSaintKlimentOhridskisDay diff --git a/src/CarbonMacrosServiceProvider.php b/src/CarbonMacrosServiceProvider.php index a80837e..f9117f5 100644 --- a/src/CarbonMacrosServiceProvider.php +++ b/src/CarbonMacrosServiceProvider.php @@ -14,6 +14,7 @@ use CarbonMacros\Traits\ItalianDates; use CarbonMacros\Traits\KenyanDates; use CarbonMacros\Traits\MultiNationalDates; +use CarbonMacros\Traits\NorthMacedonianDates; use CarbonMacros\Traits\SwedishDates; use CarbonMacros\Traits\UkrainianDates; use CarbonMacros\Traits\UsDates; @@ -35,6 +36,7 @@ class CarbonMacrosServiceProvider extends ServiceProvider IndonesianDates, ItalianDates, KenyanDates, + NorthMacedonianDates, SwedishDates, UkrainianDates, UsDates, @@ -70,6 +72,8 @@ public function register() $this->registerKenyanDates(); + $this->registerNorthMacedonianDates(); + $this->registerSwedishDates(); $this->registerUsDates(); diff --git a/src/Traits/NorthMacedonianDates.php b/src/Traits/NorthMacedonianDates.php new file mode 100644 index 0000000..60e8a1f --- /dev/null +++ b/src/Traits/NorthMacedonianDates.php @@ -0,0 +1,79 @@ +month === 1 && $this->day === 6; + }); + + Carbon::macro('isOrthodoxChristmasDay', function () { + // Orthodox Christmas Day - 7th January + return $this->month === 1 && $this->day === 7; + }); + + Carbon::macro('isDayOffForOrthodoxChristmasDay', function () { + // Day off for Orthodox Christmas Day - 8th January + return $this->month === 1 && $this->day === 8; + }); + + Carbon::macro('isOrthodoxEpiphany', function () { + // Epiphany (Orthodox) - 19th January + return $this->month === 1 && $this->day === 19; + }); + + Carbon::macro('isNorthMacedonianLaborDay', function () { + // Labor Day - 1st May + return $this->month === 5 && $this->day === 1; + }); + + Carbon::macro('isNorthMacedonianRepublicDay', function () { + // Republic Day - 2nd August + // Day when the Republic was proclaimed in 1944, also the proclamation of the Ilinden uprising in 1903 + return $this->month === 8 && $this->day === 2; + }); + + Carbon::macro('isFeastOfTheAssumptionOfMaryOrthodox', function () { + // Feast of the Assumption of Mary (Orthodox) - 28th August + return $this->month === 8 && $this->day === 28; + }); + + Carbon::macro('isNorthMacedonianIndependenceDay', function () { + // Independence Day - 8th September + // Day of independence from Yugoslavia in 1991 + return $this->month === 9 && $this->day === 8; + }); + + Carbon::macro('isNorthMacedonianDayOfPeoplesUprising', function () { + // Day of People's Uprising - 11th October + // Symbolic beginning of the Macedonian anti-fascist resistance during WWII in 1941 + return $this->month === 10 && $this->day === 11; + }); + + Carbon::macro('isDayOfTheMacedonianRevolutionaryStruggle', function () { + // Day of the Macedonian Revolutionary Struggle - 23rd October + // Day when the Internal Macedonian Revolutionary Organization (IMRO) was established in 1893. + return $this->month === 10 && $this->day === 23; + }); + + Carbon::macro('isNorthMacedonianSaintKlimentOhridskisDay', function () { + // Saint Kliment Ohridski's Day - 8th December + return $this->month === 12 && $this->day === 8; + }); + } +} \ No newline at end of file diff --git a/tests/NorthMacedonianHolidaysTest.php b/tests/NorthMacedonianHolidaysTest.php new file mode 100644 index 0000000..0700877 --- /dev/null +++ b/tests/NorthMacedonianHolidaysTest.php @@ -0,0 +1,120 @@ +assertSame($validity, $date->isNorthMacedonianHoliday()); + } + + public function provideNorthMacedonianIndependenceDayData(): array + { + return [ + '1900-12-25' => ['1900-12-25', false], + '1900-01-01' => ['1900-01-01', false], + '1920-09-08' => ['1920-09-08', true], // Independence Day + '1950-01-01' => ['1950-01-01', false], + '1980-04-24' => ['1980-04-24', false], // Day of the Cyrillic Alphabet + '1982-09-08' => ['1982-09-08', true], // Independence Day + '2010-01-01' => ['2010-01-01', false], + '2011-09-08' => ['2011-09-08', true], // Independence Day + '2013-09-08' => ['2013-09-08', true], // Independence Day + '2014-09-08' => ['2014-09-08', true], // Independence Day + '2021-01-01' => ['2021-01-01', false], + '2021-09-08' => ['2021-09-08', true], // Independence Day + '2050-09-08' => ['2050-09-08', true], // Independence Day + ]; + } + + /** + * @dataProvider provideNorthMacedonianRepublicDayData + */ + public function test_it_knows_north_macedonian_republic_day($date, $validity) + { + $date = Carbon::parse($date); + + $this->assertSame($validity, $date->isNorthMacedonianRepublicDay()); + } + + public function provideNorthMacedonianRepublicDayData(): array + { + return [ + '1900-12-25' => ['1900-12-25', false], + '1900-01-01' => ['1900-01-01', false], + '1920-09-08' => ['1920-09-08', false], // Independence Day + '1950-01-01' => ['1950-01-01', false], + '1980-04-24' => ['1980-04-24', false], // Day of the Cyrillic Alphabet + '1982-09-08' => ['1982-09-08', false], // Independence Day + '2010-01-01' => ['2010-01-01', false], + '2011-09-08' => ['2011-09-08', false], // Independence Day + '2013-09-08' => ['2013-09-08', false], // Independence Day + '2014-09-08' => ['2014-09-08', false], // Independence Day + '2021-01-01' => ['2021-01-01', false], + '2021-09-08' => ['2021-09-08', false], // Independence Day + '2050-09-08' => ['2050-09-08', false], // Independence Day + '1900-08-02' => ['1900-08-02', true], // Republic Day + '1900-10-11' => ['1900-10-11', false], // Day of People's Uprising + '1920-08-02' => ['1920-08-02', true], // Republic Day + '1950-08-02' => ['1950-08-02', true], // Republic Day + '1980-08-02' => ['1980-08-02', true], // Republic Day + '1982-08-02' => ['1982-08-02', true], // Republic Day + '2010-08-02' => ['2010-08-02', true], // Republic Day + '2011-08-02' => ['2011-08-02', true], // Republic Day + '2013-08-02' => ['2013-08-02', true], // Republic Day + '2014-08-02' => ['2014-08-02', true], // Republic Day + '2021-08-02' => ['2021-08-02', true], // Republic Day + '2050-08-02' => ['2050-08-02', true], // Republic Day + ]; + } + + /** + * @dataProvider provideNorthMacedonianDayOfPeoplesUprisingData + */ + public function test_it_knows_north_macedonian_day_of_peoples_uprising($date, $validity) + { + $date = Carbon::parse($date); + + $this->assertSame($validity, $date->isNorthMacedonianDayOfPeoplesUprising()); + } + + public function provideNorthMacedonianDayOfPeoplesUprisingData(): array + { + return [ + '1900-12-25' => ['1900-12-25', false], + '1900-01-01' => ['1900-01-01', false], + '1920-09-08' => ['1920-09-08', false], // Independence Day + '1950-01-01' => ['1950-01-01', false], + '1980-04-24' => ['1980-04-24', false], // Day of the Cyrillic Alphabet + '1982-09-08' => ['1982-09-08', false], // Independence Day + '2010-01-01' => ['2010-01-01', false], + '2011-09-08' => ['2011-09-08', false], // Independence Day + '2013-09-08' => ['2013-09-08', false], // Independence Day + '2014-09-08' => ['2014-09-08', false], // Independence Day + '2021-01-01' => ['2021-01-01', false], + '2021-09-08' => ['2021-09-08', false], // Independence Day + '2050-09-08' => ['2050-09-08', false], // Independence Day + '1900-08-02' => ['1900-08-02', false], // Republic Day + '1900-10-11' => ['1900-10-11', true], // Day of People's Uprising + '1920-10-11' => ['1920-10-11', true], // Day of People's Uprising + '1950-10-11' => ['1950-10-11', true], // Day of People's Uprising + '1980-10-11' => ['1980-10-11', true], // Day of People's Uprising + '1982-10-11' => ['1982-10-11', true], // Day of People's Uprising + '2010-10-11' => ['2010-10-11', true], // Day of People's Uprising + '2011-10-11' => ['2011-10-11', true], // Day of People's Uprising + '2013-10-11' => ['2013-10-11', true], // Day of People's Uprising + '2014-10-11' => ['2014-10-11', true], // Day of People's Uprising + '2021-10-11' => ['2021-10-11', true], // Day of People's Uprising + '2050-10-11' => ['2050-10-11', true], // Day of People's Uprising + ]; + } + +} \ No newline at end of file