Skip to content

Commit

Permalink
Merge pull request #57 from KiritoXD01/main
Browse files Browse the repository at this point in the history
Added Dominican Republic holidays
  • Loading branch information
Nielsvanpach authored Jan 20, 2024
2 parents 44a846a + d30d056 commit 0ba6819
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/Countries/DominicanRepublic.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace Spatie\Holidays\Countries;

use Carbon\CarbonImmutable;

class DominicanRepublic extends Country
{
public function countryCode(): string
{
return 'do';
}

/** @return array<string, CarbonImmutable | string> */
protected function allHolidays(int $year): array
{
return [
'Año Nuevo' => '01-01',
'Día de la Altagracia' => '01-21',
'Día de Duarte' => '01-26',
'Día de la Independencia' => '02-27',
'Día del Trabajo' => '05-01',
'Día de la Restauración' => '08-16',
'Día de las Mercedes' => '09-24',
'Día de la Constitución' => '11-06',
'Navidad' => '12-25',
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[
{
"name": "A\u00f1o Nuevo",
"date": "2024-01-01"
},
{
"name": "D\u00eda de la Altagracia",
"date": "2024-01-21"
},
{
"name": "D\u00eda de Duarte",
"date": "2024-01-26"
},
{
"name": "D\u00eda de la Independencia",
"date": "2024-02-27"
},
{
"name": "D\u00eda del Trabajo",
"date": "2024-05-01"
},
{
"name": "D\u00eda de la Restauraci\u00f3n",
"date": "2024-08-16"
},
{
"name": "D\u00eda de las Mercedes",
"date": "2024-09-24"
},
{
"name": "D\u00eda de la Constituci\u00f3n",
"date": "2024-11-06"
},
{
"name": "Navidad",
"date": "2024-12-25"
}
]
19 changes: 19 additions & 0 deletions tests/Countries/DominicanRepublicTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace Spatie\Holidays\Tests\Countries;

use Carbon\CarbonImmutable;
use Spatie\Holidays\Holidays;

it('can calculate dominican republic holidays', function () {
CarbonImmutable::setTestNowAndTimezone('2024-01-01');

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

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

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

0 comments on commit 0ba6819

Please sign in to comment.