Skip to content

Commit

Permalink
Added Haiti holidays (#148)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanmercedes authored Jan 23, 2024
1 parent 48bb3ba commit 07454e6
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 0 deletions.
41 changes: 41 additions & 0 deletions src/Countries/Haiti.php
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),
];
}
}
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"
}
]
18 changes: 18 additions & 0 deletions tests/Countries/HaitiTest.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 haiti holidays', function () {
CarbonImmutable::setTestNowAndTimezone('2024-01-01');

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

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

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

0 comments on commit 07454e6

Please sign in to comment.