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.
* add: guatemalan holidays * Add guatemalan holidays --------- Co-authored-by: ejchiroy <[email protected]>
- Loading branch information
Showing
3 changed files
with
98 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,38 @@ | ||
<?php | ||
|
||
namespace Spatie\Holidays\Countries; | ||
|
||
use Carbon\CarbonImmutable; | ||
|
||
class Guatemala extends Country | ||
{ | ||
public function countryCode(): string | ||
{ | ||
return 'gt'; | ||
} | ||
|
||
protected function allHolidays(int $year): array | ||
{ | ||
return array_merge([ | ||
'Año Nuevo' => '01-01', | ||
'Día de los Trabajadores' => '05-01', | ||
'Día del Ejército' => '06-31', | ||
'Día de la Independencia' => '09-15', | ||
'Día de la Revolución' => '10-20', | ||
'Día de Todos los Santos' => '11-01', | ||
'Navidad' => '12-25', | ||
], $this->variableHolidays($year)); | ||
} | ||
|
||
/** @return array<string, CarbonImmutable> */ | ||
protected function variableHolidays(int $year): array | ||
{ | ||
$easter = $this->easter($year); | ||
|
||
return [ | ||
'Jueves Santo' => $easter->subDays(3), | ||
'Viernes Santo' => $easter->subDays(2), | ||
'Sábado Santo' => $easter->subDays(1), | ||
]; | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
tests/.pest/snapshots/Countries/GuatemalaTest/it_can_calculate_guatemalan_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,42 @@ | ||
[ | ||
{ | ||
"name": "A\u00f1o Nuevo", | ||
"date": "2024-01-01" | ||
}, | ||
{ | ||
"name": "Jueves Santo", | ||
"date": "2024-03-28" | ||
}, | ||
{ | ||
"name": "Viernes Santo", | ||
"date": "2024-03-29" | ||
}, | ||
{ | ||
"name": "S\u00e1bado Santo", | ||
"date": "2024-03-30" | ||
}, | ||
{ | ||
"name": "D\u00eda de los Trabajadores", | ||
"date": "2024-05-01" | ||
}, | ||
{ | ||
"name": "D\u00eda del Ej\u00e9rcito", | ||
"date": "2024-07-01" | ||
}, | ||
{ | ||
"name": "D\u00eda de la Independencia", | ||
"date": "2024-09-15" | ||
}, | ||
{ | ||
"name": "D\u00eda de la Revoluci\u00f3n", | ||
"date": "2024-10-20" | ||
}, | ||
{ | ||
"name": "D\u00eda de Todos los Santos", | ||
"date": "2024-11-01" | ||
}, | ||
{ | ||
"name": "Navidad", | ||
"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 guatemalan holidays', function () { | ||
CarbonImmutable::setTestNowAndTimezone('2024-01-01'); | ||
|
||
$holidays = Holidays::for(country: 'gt')->get(); | ||
|
||
expect($holidays) | ||
->toBeArray() | ||
->not()->toBeEmpty(); | ||
|
||
expect(formatDates($holidays))->toMatchSnapshot(); | ||
}); |