generated from spatie/package-skeleton-php
-
-
Notifications
You must be signed in to change notification settings - Fork 197
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add Estonian holidays * Use easter() method for easter date
- Loading branch information
Showing
3 changed files
with
108 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,40 @@ | ||
<?php | ||
|
||
namespace Spatie\Holidays\Countries; | ||
|
||
use Carbon\CarbonImmutable; | ||
|
||
class Estonia extends Country | ||
{ | ||
public function countryCode(): string | ||
{ | ||
return 'ee'; | ||
} | ||
|
||
protected function allHolidays(int $year): array | ||
{ | ||
return array_merge([ | ||
'Uusaasta' => '01-01', | ||
'Iseseisvuspäev' => '02-24', | ||
'Kevadpüha' => '05-01', | ||
'Võidupüha' => '06-23', | ||
'Jaanipäev' => '06-24', | ||
'Taasiseseisvumispäev' => '08-20', | ||
'Jõululaupäev' => '12-24', | ||
'Esimene jõulupüha' => '12-25', | ||
'Teine jõulupüha' => '12-26', | ||
], $this->variableHolidays($year)); | ||
} | ||
|
||
/** @return array<string, CarbonImmutable> */ | ||
protected function variableHolidays(int $year): array | ||
{ | ||
$easter = $this->easter($year); | ||
|
||
return [ | ||
'Suur reede' => $easter->subDays(2), | ||
'Ülestõusmispühade 1. püha' => $easter, | ||
'Nelipühade 1. püha' => $easter->addDays(49), | ||
]; | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
tests/.pest/snapshots/Countries/EstoniaTest/it_can_calculate_estonian_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,50 @@ | ||
[ | ||
{ | ||
"name": "Uusaasta", | ||
"date": "2024-01-01" | ||
}, | ||
{ | ||
"name": "Iseseisvusp\u00e4ev", | ||
"date": "2024-02-24" | ||
}, | ||
{ | ||
"name": "Suur reede", | ||
"date": "2024-03-29" | ||
}, | ||
{ | ||
"name": "\u00dclest\u00f5usmisp\u00fchade 1. p\u00fcha", | ||
"date": "2024-03-31" | ||
}, | ||
{ | ||
"name": "Kevadp\u00fcha", | ||
"date": "2024-05-01" | ||
}, | ||
{ | ||
"name": "Nelip\u00fchade 1. p\u00fcha", | ||
"date": "2024-05-19" | ||
}, | ||
{ | ||
"name": "V\u00f5idup\u00fcha", | ||
"date": "2024-06-23" | ||
}, | ||
{ | ||
"name": "Jaanip\u00e4ev", | ||
"date": "2024-06-24" | ||
}, | ||
{ | ||
"name": "Taasiseseisvumisp\u00e4ev", | ||
"date": "2024-08-20" | ||
}, | ||
{ | ||
"name": "J\u00f5ululaup\u00e4ev", | ||
"date": "2024-12-24" | ||
}, | ||
{ | ||
"name": "Esimene j\u00f5ulup\u00fcha", | ||
"date": "2024-12-25" | ||
}, | ||
{ | ||
"name": "Teine j\u00f5ulup\u00fcha", | ||
"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,18 @@ | ||
<?php | ||
|
||
namespace Spatie\Holidays\Tests\Countries; | ||
|
||
use Carbon\CarbonImmutable; | ||
use Spatie\Holidays\Holidays; | ||
|
||
it('can calculate estonian holidays', function () { | ||
CarbonImmutable::setTestNowAndTimezone('2024-01-01', 'Europe/Tallinn'); | ||
|
||
$holidays = Holidays::for(country: 'ee')->get(); | ||
|
||
expect($holidays) | ||
->toBeArray() | ||
->not()->toBeEmpty(); | ||
|
||
expect(formatDates($holidays))->toMatchSnapshot(); | ||
}); |