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.
- Loading branch information
Showing
3 changed files
with
104 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,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), | ||
]; | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
tests/.pest/snapshots/Countries/LuxembourgTest/it_can_calculate_luxembourgish_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,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" | ||
} | ||
] |
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 luxembourgish holidays', function () { | ||
CarbonImmutable::setTestNowAndTimezone('2024-01-01'); | ||
|
||
$holidays = Holidays::for(country: 'lu')->get(); | ||
|
||
expect($holidays) | ||
->toBeArray() | ||
->not()->toBeEmpty(); | ||
|
||
expect(formatDates($holidays))->toMatchSnapshot(); | ||
}); |