Skip to content

Commit

Permalink
Add Luxembourgish holidays
Browse files Browse the repository at this point in the history
  • Loading branch information
dlquattro committed Jan 18, 2024
1 parent d8cbb76 commit a9b79b4
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/Countries/Luxembourg.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

namespace Spatie\Holidays\Countries;

use Carbon\CarbonImmutable;

class Luxembourg extends Country
{
public function countryCode(): string
{
return 'lu';
}

protected function allHolidays(int $year): array
{
return array_merge([
'Nouvel An' => '01-01',
'Premier Mai' => '05-01',
'Journée de l\'Europe' => '05-09',
'Fête nationale' => '06-23',
'Assomption' => '08-15',
'Toussaint' => '11-01',
'Noël' => '12-25',
'Saint Étienne' => '12-26',
], $this->variableHolidays($year));
}

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

return [
'Lundi de Pâques' => $easter->addDay(),
'Ascension' => $easter->addDays(39),
'Lundi de Pentecôte' => $easter->addDays(50),
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[
{
"name": "Nouvel An",
"date": "2024-01-01"
},
{
"name": "Lundi de P\u00e2ques",
"date": "2024-04-01"
},
{
"name": "Premier Mai",
"date": "2024-05-01"
},
{
"name": "Ascension",
"date": "2024-05-09"
},
{
"name": "Journ\u00e9e de l'Europe",
"date": "2024-05-09"
},
{
"name": "Lundi de Pentec\u00f4te",
"date": "2024-05-20"
},
{
"name": "F\u00eate nationale",
"date": "2024-06-23"
},
{
"name": "Assomption",
"date": "2024-08-15"
},
{
"name": "Toussaint",
"date": "2024-11-01"
},
{
"name": "No\u00ebl",
"date": "2024-12-25"
},
{
"name": "Saint \u00c9tienne",
"date": "2024-12-26"
}
]
18 changes: 18 additions & 0 deletions tests/Countries/LuxembourgTest.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 luxembourgish holidays', function () {
CarbonImmutable::setTestNowAndTimezone('2024-01-01');

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

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

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

0 comments on commit a9b79b4

Please sign in to comment.