Skip to content

Commit

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

* Use easter() method for easter date
  • Loading branch information
hulkur authored Jan 19, 2024
1 parent dc932c8 commit aad7d49
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/Countries/Estonia.php
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),
];
}
}
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"
}
]
18 changes: 18 additions & 0 deletions tests/Countries/EstoniaTest.php
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();
});

0 comments on commit aad7d49

Please sign in to comment.