generated from spatie/package-skeleton-php
-
-
Notifications
You must be signed in to change notification settings - Fork 198
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
1 parent
48bb3ba
commit 07454e6
Showing
3 changed files
with
109 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,41 @@ | ||
<?php | ||
|
||
namespace Spatie\Holidays\Countries; | ||
|
||
use Carbon\CarbonImmutable; | ||
|
||
class Haiti extends Country | ||
{ | ||
public function countryCode(): string | ||
{ | ||
return 'ht'; | ||
} | ||
|
||
/** @return array<string, CarbonImmutable | string> */ | ||
protected function allHolidays(int $year): array | ||
{ | ||
return array_merge([ | ||
'Nouvel an / Jour de l\'Indépendance' => '01-01', | ||
'Jour des Aieux' => '01-2', | ||
'Fête du Travail / Fête des Travailleurs' => '05-01', | ||
'Jour du Drapeau et de l\'Université' => '05-18', | ||
'L\'Assomption de Marie' => '08-15', | ||
'Anniversaire de la mort de Dessalines' => '10-17', | ||
'Toussaint' => '11-01', | ||
'Jour des Morts' => '11-02', | ||
'Vertières' => '11-18', | ||
'Noël' => '12-25', | ||
], $this->variableHolidays($year)); | ||
} | ||
|
||
/** @return array<string, CarbonImmutable> */ | ||
protected function variableHolidays(int $year): array | ||
{ | ||
$easter = $this->easter($year); | ||
|
||
return [ | ||
'Carnaval/Mardi Gras' => $easter->subDays(47), | ||
'Vendredi saint' => $easter->subDays(2), | ||
]; | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
tests/.pest/snapshots/Countries/HaitiTest/it_can_calculate_haiti_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,50 @@ | ||
[ | ||
{ | ||
"name": "Nouvel an \/ Jour de l'Ind\u00e9pendance", | ||
"date": "2024-01-01" | ||
}, | ||
{ | ||
"name": "Jour des Aieux", | ||
"date": "2024-01-02" | ||
}, | ||
{ | ||
"name": "Carnaval\/Mardi Gras", | ||
"date": "2024-02-13" | ||
}, | ||
{ | ||
"name": "Vendredi saint", | ||
"date": "2024-03-29" | ||
}, | ||
{ | ||
"name": "F\u00eate du Travail \/ F\u00eate des Travailleurs", | ||
"date": "2024-05-01" | ||
}, | ||
{ | ||
"name": "Jour du Drapeau et de l'Universit\u00e9", | ||
"date": "2024-05-18" | ||
}, | ||
{ | ||
"name": "L'Assomption de Marie", | ||
"date": "2024-08-15" | ||
}, | ||
{ | ||
"name": "Anniversaire de la mort de Dessalines", | ||
"date": "2024-10-17" | ||
}, | ||
{ | ||
"name": "Toussaint", | ||
"date": "2024-11-01" | ||
}, | ||
{ | ||
"name": "Jour des Morts", | ||
"date": "2024-11-02" | ||
}, | ||
{ | ||
"name": "Verti\u00e8res", | ||
"date": "2024-11-18" | ||
}, | ||
{ | ||
"name": "No\u00ebl", | ||
"date": "2024-12-25" | ||
} | ||
] |
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 haiti holidays', function () { | ||
CarbonImmutable::setTestNowAndTimezone('2024-01-01'); | ||
|
||
$holidays = Holidays::for(country: 'ht')->get(); | ||
|
||
expect($holidays) | ||
->toBeArray() | ||
->not()->toBeEmpty(); | ||
|
||
expect(formatDates($holidays))->toMatchSnapshot(); | ||
}); |