generated from spatie/package-skeleton-php
-
-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add romanian holidays * add Epiphany and Saint John public holidays * fix static analysis * Fix styling * add formula to calculate the difference between Julian and Gregorian calendars * Fix styling * add the source of the orthodox easter algorithm * Fix styling * fix phpstan * remove orthodoxEaster function from Romania class
- Loading branch information
Showing
3 changed files
with
149 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
namespace Spatie\Holidays\Countries; | ||
|
||
use Carbon\CarbonImmutable; | ||
|
||
class Romania extends Country | ||
{ | ||
public function countryCode(): string | ||
{ | ||
return 'ro'; | ||
} | ||
|
||
/** @return array<string, string|CarbonImmutable> */ | ||
protected function allHolidays(int $year): array | ||
{ | ||
return array_merge([ | ||
'Anul Nou' => '01-01', | ||
'A doua zi de Anul Nou' => '01-02', | ||
'Bobotează' => '01-06', | ||
'Sfântul Ion' => '01-07', | ||
'Ziua Unirii Principatelor Române' => '01-24', | ||
'Ziua Muncii' => '05-01', | ||
'Ziua Copilului' => '06-01', | ||
'Adormirea Maicii Domnului' => '08-15', | ||
'Sfântul Andrei' => '11-30', | ||
'Ziua Națională' => '12-01', | ||
'Crăciunul' => '12-25', | ||
'A doua zi de Crăciun' => '12-26', | ||
], $this->variableHolidays($year)); | ||
} | ||
|
||
/** | ||
* @return array<string, CarbonImmutable> | ||
*/ | ||
protected function variableHolidays(int $year): array | ||
{ | ||
$easter = $this->orthodoxEaster($year); | ||
$easterMonday = $easter->addDay(); | ||
$goodFriday = $easter->subDays(2); | ||
|
||
$pentecost = $this->orthodoxPentecost($year); | ||
$pentecostMonday = $pentecost->addDay(); | ||
|
||
return [ | ||
'Vinerea Mare' => $goodFriday, | ||
'Paștele' => $easter, | ||
'A doua zi de Paște' => $easterMonday, | ||
'Rusaliile' => $pentecost, | ||
'A doua zi de Rusalii' => $pentecostMonday, | ||
]; | ||
} | ||
|
||
protected function orthodoxPentecost(int $year): CarbonImmutable | ||
{ | ||
$easter = $this->orthodoxEaster($year); | ||
|
||
return $easter->addDays(49); | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
tests/.pest/snapshots/Countries/RomaniaTest/it_can_calculate_romanian_holidays.snap
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,70 @@ | ||
[ | ||
{ | ||
"name": "Anul Nou", | ||
"date": "2024-01-01" | ||
}, | ||
{ | ||
"name": "A doua zi de Anul Nou", | ||
"date": "2024-01-02" | ||
}, | ||
{ | ||
"name": "Boboteaz\u0103", | ||
"date": "2024-01-06" | ||
}, | ||
{ | ||
"name": "Sf\u00e2ntul Ion", | ||
"date": "2024-01-07" | ||
}, | ||
{ | ||
"name": "Ziua Unirii Principatelor Rom\u00e2ne", | ||
"date": "2024-01-24" | ||
}, | ||
{ | ||
"name": "Ziua Muncii", | ||
"date": "2024-05-01" | ||
}, | ||
{ | ||
"name": "Vinerea Mare", | ||
"date": "2024-05-03" | ||
}, | ||
{ | ||
"name": "Pa\u0219tele", | ||
"date": "2024-05-05" | ||
}, | ||
{ | ||
"name": "A doua zi de Pa\u0219te", | ||
"date": "2024-05-06" | ||
}, | ||
{ | ||
"name": "Ziua Copilului", | ||
"date": "2024-06-01" | ||
}, | ||
{ | ||
"name": "Rusaliile", | ||
"date": "2024-06-23" | ||
}, | ||
{ | ||
"name": "A doua zi de Rusalii", | ||
"date": "2024-06-24" | ||
}, | ||
{ | ||
"name": "Adormirea Maicii Domnului", | ||
"date": "2024-08-15" | ||
}, | ||
{ | ||
"name": "Sf\u00e2ntul Andrei", | ||
"date": "2024-11-30" | ||
}, | ||
{ | ||
"name": "Ziua Na\u021bional\u0103", | ||
"date": "2024-12-01" | ||
}, | ||
{ | ||
"name": "Cr\u0103ciunul", | ||
"date": "2024-12-25" | ||
}, | ||
{ | ||
"name": "A doua zi de Cr\u0103ciun", | ||
"date": "2024-12-26" | ||
} | ||
] |
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,19 @@ | ||
<?php | ||
|
||
namespace Spatie\Holidays\Tests\Countries; | ||
|
||
use Carbon\CarbonImmutable; | ||
use Spatie\Holidays\Holidays; | ||
|
||
it('can calculate romanian holidays', function () { | ||
CarbonImmutable::setTestNowAndTimezone('2024-01-01'); | ||
|
||
$holidays = Holidays::for(country: 'ro')->get(); | ||
|
||
expect($holidays) | ||
->toBeArray() | ||
->not()->toBeEmpty(); | ||
|
||
expect(formatDates($holidays))->toMatchSnapshot(); | ||
|
||
}); |