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

Added NorthMacedonia Public Holidays #28

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
13 changes: 13 additions & 0 deletions docs/northmacedonia.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
### North Macedonian dates

- `isOrthodoxChristmasEve
- `isOrthodoxChristmasDay
- `isDayOffForOrthodoxChristmasDay
- `isOrthodoxEpiphany
- `isNorthMacedonianLaborDay
- `isNorthMacedonianRepublicDay
- `isFeastOfTheAssumptionOfMaryOrthodox
- `isNorthMacedonianIndependenceDay
- `isNorthMacedonianDayOfPeoplesUprising
- `isDayOfTheMacedonianRevolutionaryStruggle
- `isNorthMacedonianSaintKlimentOhridskisDay
4 changes: 4 additions & 0 deletions src/CarbonMacrosServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -35,6 +36,7 @@ class CarbonMacrosServiceProvider extends ServiceProvider
IndonesianDates,
ItalianDates,
KenyanDates,
NorthMacedonianDates,
SwedishDates,
UkrainianDates,
UsDates,
Expand Down Expand Up @@ -70,6 +72,8 @@ public function register()

$this->registerKenyanDates();

$this->registerNorthMacedonianDates();

$this->registerSwedishDates();

$this->registerUsDates();
Expand Down
79 changes: 79 additions & 0 deletions src/Traits/NorthMacedonianDates.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?php

namespace CarbonMacros\Traits;

use Illuminate\Support\Carbon;

/**
*
*/
trait NorthMacedonianDates
{
public function registerNorthMacedonianDates(): void
{
/*
* https://en.wikipedia.org/wiki/Public_holidays_in_North_Macedonia
*
Only public holidays will be registered, as they apply for all citizens,
regardless od ethnic or religious background
*/
Carbon::macro('isOrthodoxChristmasEve', function () {
// Orthodox Christmas Eve - 6th January
return $this->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;
});
}
}
120 changes: 120 additions & 0 deletions tests/NorthMacedonianHolidaysTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
<?php

namespace CarbonMacros;

use Illuminate\Support\Carbon;

class NorthMacedonianHolidaysTest extends TestCase
{
/**
* @dataProvider provideNorthMacedonianIndependenceDayData
*/
public function test_it_knows_north_macedonian_independence_day($date, $validity)
{
$date = Carbon::parse($date);

$this->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
];
}

}