Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Lithuanian holidays #163

Merged
merged 1 commit into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions src/Countries/Lithuania.php
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(),
];
}
}
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"
}
]
18 changes: 18 additions & 0 deletions tests/Countries/LithuaniaTest.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 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();
});
Loading