generated from spatie/package-skeleton-php
-
-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #163 from eimantaaas/main
Add Lithuanian holidays
- Loading branch information
Showing
3 changed files
with
118 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,42 @@ | ||
<?php | ||
|
||
namespace Spatie\Holidays\Countries; | ||
|
||
use Carbon\CarbonImmutable; | ||
|
||
class Lithuania extends Country | ||
{ | ||
public function countryCode(): string | ||
{ | ||
return 'lt'; | ||
} | ||
|
||
protected function allHolidays(int $year): array | ||
{ | ||
return array_merge([ | ||
'Naujieji metai' => '01-01', | ||
'Lietuvos valstybės atkūrimo diena' => '02-16', | ||
'Nepriklausomybės atkūrimo diena' => '03-11', | ||
'Tarptautinė darbo diena' => '05-01', | ||
'Joninės' => '06-24', | ||
'Karaliaus Mindaugo karūnavimo diena' => '07-06', | ||
'Žolinė' => '08-15', | ||
'Visų šventųjų diena' => '11-01', | ||
'Vėlinės' => '11-02', | ||
'Šv. Kūčios' => '12-24', | ||
'Šv. Kalėdos' => '12-25', | ||
'Šv. Kalėdų antroji diena' => '12-26', | ||
], $this->variableHolidays($year)); | ||
} | ||
|
||
/** @return array<string, CarbonImmutable> */ | ||
protected function variableHolidays(int $year): array | ||
{ | ||
$easter = $this->easter($year); | ||
|
||
return [ | ||
'Velykos' => $easter, | ||
'Velykų antroji diena' => $easter->addDay(), | ||
]; | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
tests/.pest/snapshots/Countries/LithuaniaTest/it_can_calculate_lithuanian_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,58 @@ | ||
[ | ||
{ | ||
"name": "Naujieji metai", | ||
"date": "2024-01-01" | ||
}, | ||
{ | ||
"name": "Lietuvos valstyb\u0117s atk\u016brimo diena", | ||
"date": "2024-02-16" | ||
}, | ||
{ | ||
"name": "Nepriklausomyb\u0117s atk\u016brimo diena", | ||
"date": "2024-03-11" | ||
}, | ||
{ | ||
"name": "Velykos", | ||
"date": "2024-03-31" | ||
}, | ||
{ | ||
"name": "Velyk\u0173 antroji diena", | ||
"date": "2024-04-01" | ||
}, | ||
{ | ||
"name": "Tarptautin\u0117 darbo diena", | ||
"date": "2024-05-01" | ||
}, | ||
{ | ||
"name": "Jonin\u0117s", | ||
"date": "2024-06-24" | ||
}, | ||
{ | ||
"name": "Karaliaus Mindaugo kar\u016bnavimo diena", | ||
"date": "2024-07-06" | ||
}, | ||
{ | ||
"name": "\u017dolin\u0117", | ||
"date": "2024-08-15" | ||
}, | ||
{ | ||
"name": "Vis\u0173 \u0161vent\u0173j\u0173 diena", | ||
"date": "2024-11-01" | ||
}, | ||
{ | ||
"name": "V\u0117lin\u0117s", | ||
"date": "2024-11-02" | ||
}, | ||
{ | ||
"name": "\u0160v. K\u016b\u010dios", | ||
"date": "2024-12-24" | ||
}, | ||
{ | ||
"name": "\u0160v. Kal\u0117dos", | ||
"date": "2024-12-25" | ||
}, | ||
{ | ||
"name": "\u0160v. Kal\u0117d\u0173 antroji diena", | ||
"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 lithuanian holidays', function () { | ||
CarbonImmutable::setTestNowAndTimezone('2024-01-01', 'Europe/Vilnius'); | ||
|
||
$holidays = Holidays::for(country: 'lt')->get(); | ||
|
||
expect($holidays) | ||
->toBeArray() | ||
->not()->toBeEmpty(); | ||
|
||
expect(formatDates($holidays))->toMatchSnapshot(); | ||
}); |