Skip to content

Commit

Permalink
poland
Browse files Browse the repository at this point in the history
  • Loading branch information
fizgiel authored and srsbiz committed Jan 21, 2024
1 parent 5d4f44e commit 6b67761
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 0 deletions.
43 changes: 43 additions & 0 deletions src/Countries/Poland.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

namespace Spatie\Holidays\Countries;

use Carbon\CarbonImmutable;

class Poland extends Country
{
public function countryCode(): string
{
return 'pl';
}

/** @return array<string, CarbonImmutable> */
protected function allHolidays(int $year): array
{
return array_merge([
'Nowy Rok' => '01-01',
'Święto Trzech Króli' => '01-06',
'Święto Pracy' => '05-01',
'Święto Konstytucji 3 Maja' => '05-03',
'Święto Wojska Polskiego, Wniebowzięcie Najświętszej Maryi Panny' => '08-15',
'Wszystkich Świętych' => '11-01',
'Święto Niepodległości' => '11-11',
'Boże Narodzenie' => '12-25',
'Boże Narodzenie' => '12-26',
], $this->variableHolidays($year));
}

/** @return array<string, CarbonImmutable> */
protected function variableHolidays(int $year): array
{
$easter = CarbonImmutable::createFromTimestamp(easter_date($year))->setTimezone('Europe/Warsaw');

return [
'Wielkanoc' => $easter,
'Poniedziałek Wielkanocny' => $easter->addDay(),
'Zielone Świątki' => $easter->addWeeks(7),
'Boże Ciało' => $easter->addDays(60),

];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
[
{
"name": "Nowy Rok",
"date": "2024-01-01"
},
{
"name": "Święto Trzech Króli",
"date": "2024-01-06"
},
{
"name": "Święto Pracy",
"date": "2024-05-01"
},
{
"name": "Święto Konstytucji 3 Maja",
"date": "2024-05-03"
},
{
"name": "Święto Wojska Polskiego, Wniebowzięcie Najświętszej Maryi Panny",
"date": "2024-08-15"
},
{
"name": "Wszystkich Świętych",
"date": "2024-11-01"
},
{
"name": "Święto Niepodległości",
"date": "2024-11-11"
},
{
"name": "Boże Narodzenie",
"date": "2024-12-25"
},
{
"name": "Boże Narodzenie",
"date": "2024-12-26"
},
{
"name": "Wielkanoc",
"date": "2024-03-31"
},
{
"name": "Poniedziałek Wielkanocny",
"date": "2024-04-01"
},
{
"name": "Zielone Świątki",
"date": "2024-05-19"
},
{
"name": "Boże Ciało",
"date": "2024-05-30"
}
]
18 changes: 18 additions & 0 deletions tests/Countries/PolandTest.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 polish holidays', function () {
CarbonImmutable::setTestNowAndTimezone('2024-01-01');

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

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

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

0 comments on commit 6b67761

Please sign in to comment.