Skip to content

Commit

Permalink
Add Montenegro holidays (#171)
Browse files Browse the repository at this point in the history
* Add Montenegro holidays

* Add English and Serbian translations for Montenegro holidays

---------

Co-authored-by: Marko Ršumović <[email protected]>
  • Loading branch information
Rkishahaha and Marko Ršumović authored Jan 25, 2024
1 parent 0eb53b7 commit c73c665
Show file tree
Hide file tree
Showing 5 changed files with 169 additions and 0 deletions.
18 changes: 18 additions & 0 deletions lang/montenegro/en/holidays.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"Nova godina - prvi dan": "New Year - first day",
"Nova godina - drugi dan": "New Year - second day",
"Badnji dan": "Christmas Eve",
"Božić - prvi dan": "Christmas - first day",
"Božić - drugi dan": "Christmas - second day",
"Praznik rada - prvi dan": "Labour Day - first day",
"Praznik rada - drugi dan": "Labour Day - second day",
"Veliki petak": "Good Friday",
"Vaskrs": "Easter",
"Vaskršnji ponedjeljak": "Easter Monday",
"Dan nezavisnosti - prvi dan": "Independence Day - first day",
"Dan nezavisnosti - drugi dan": "Independence Day - second day",
"Dan državnosti - prvi dan": "National Day - first day",
"Dan državnosti - drugi dan": "National Day - second day",
"Njegošev dan - prvi dan": "Njegoš's Day - first day",
"Njegošev dan - drugi dan": "Njegoš's Day - second day"
}
18 changes: 18 additions & 0 deletions lang/montenegro/sr/holidays.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"Nova godina - prvi dan": "Nova godina - prvi dan",
"Nova godina - drugi dan": "Nova godina - drugi dan",
"Badnji dan": "Badnji dan",
"Božić - prvi dan": "Božić - prvi dan",
"Božić - drugi dan": "Božić - drugi dan",
"Praznik rada - prvi dan": "Praznik rada - prvi dan",
"Praznik rada - drugi dan": "Praznik rada - drugi dan",
"Veliki petak": "Veliki petak",
"Vaskrs": "Vaskrs",
"Vaskršnji ponedjeljak": "Vaskršnji ponedeljak",
"Dan nezavisnosti - prvi dan": "Dan nezavisnosti - prvi dan",
"Dan nezavisnosti - drugi dan": "Dan nezavisnosti - drugi dan",
"Dan državnosti - prvi dan": "Dan državnosti - prvi dan",
"Dan državnosti - drugi dan": "Dan državnosti - drugi dan",
"Njegošev dan - prvi dan": "Njegošev dan - prvi dan",
"Njegošev dan - drugi dan": "Njegošev dan - drugi dan"
}
49 changes: 49 additions & 0 deletions src/Countries/Montenegro.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

namespace Spatie\Holidays\Countries;

use Carbon\CarbonImmutable;

class Montenegro extends Country
{
public function countryCode(): string
{
return 'me';
}

public function allHolidays(int $year) : array
{
// Montenegro has two days off for most holidays
return array_merge([
'Nova godina - prvi dan' => '01-01',
'Nova godina - drugi dan' => '01-02',
'Badnji dan' => '01-06',
'Božić - prvi dan' => '01-07',
'Božić - drugi dan' => '01-08',
'Praznik rada - prvi dan' => '05-01',
'Praznik rada - drugi dan' => '05-02',
'Dan nezavisnosti - prvi dan' => '05-21',
'Dan nezavisnosti - drugi dan' => '05-22',
'Dan državnosti - prvi dan' => '07-13',
'Dan državnosti - drugi dan' => '07-14',
'Njegošev dan - prvi dan' => '11-13',
'Njegošev dan - drugi dan' => '11-14',

], $this->variableHolidays($year));
}

/** @return array<string, CarbonImmutable> */
public function variableHolidays(int $year) : array
{
// Orthodox Easter calculation needs to be in the same timezone as the country
$orthodoxEaster = $this->orthodoxEaster($year)->setTimezone('Europe/Podgorica');
$goodFriday = $orthodoxEaster->copy()->subDays(2);
$orthodoxEasterMonday = $orthodoxEaster->copy()->addDay();

return [
'Vaskrs' => $orthodoxEaster,
'Vaskršnji ponedjeljak' => $orthodoxEasterMonday,
'Veliki petak' => $goodFriday,
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
[
{
"name": "Nova godina - prvi dan",
"date": "2024-01-01"
},
{
"name": "Nova godina - drugi dan",
"date": "2024-01-02"
},
{
"name": "Badnji dan",
"date": "2024-01-06"
},
{
"name": "Bo\u017ei\u0107 - prvi dan",
"date": "2024-01-07"
},
{
"name": "Bo\u017ei\u0107 - drugi dan",
"date": "2024-01-08"
},
{
"name": "Praznik rada - prvi dan",
"date": "2024-05-01"
},
{
"name": "Praznik rada - drugi dan",
"date": "2024-05-02"
},
{
"name": "Veliki petak",
"date": "2024-05-03"
},
{
"name": "Vaskrs",
"date": "2024-05-05"
},
{
"name": "Vaskr\u0161nji ponedjeljak",
"date": "2024-05-06"
},
{
"name": "Dan nezavisnosti - prvi dan",
"date": "2024-05-21"
},
{
"name": "Dan nezavisnosti - drugi dan",
"date": "2024-05-22"
},
{
"name": "Dan dr\u017eavnosti - prvi dan",
"date": "2024-07-13"
},
{
"name": "Dan dr\u017eavnosti - drugi dan",
"date": "2024-07-14"
},
{
"name": "Njego\u0161ev dan - prvi dan",
"date": "2024-11-13"
},
{
"name": "Njego\u0161ev dan - drugi dan",
"date": "2024-11-14"
}
]
18 changes: 18 additions & 0 deletions tests/Countries/MontenegroTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Spatie\Holidays\Test;

use Carbon\CarbonImmutable;
use Spatie\Holidays\Holidays;

it('can calculate montenegro holidays', function () {
CarbonImmutable::setTestNowAndTimezone('2024-01-01');

$holidays = Holidays::for(country: 'me')->get();

expect($holidays)
->toBeArray()
->not()->toBeEmpty();

expect(formatDates($holidays))->toMatchSnapshot();
});

0 comments on commit c73c665

Please sign in to comment.