Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Panama holidays #100

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions src/Countries/Panama.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

namespace Spatie\Holidays\Countries;

use Carbon\CarbonImmutable;

class Panama extends Country
{

public function countryCode(): string
{
return 'pa';
}

protected function allHolidays(int $year): array
{
return array_merge([
'Año Nuevo' => '01-01',
'Día de los Mártires' => '01-09',
'Día del Trabajo' => '05-01',
'Separación de Panamá de Colombia' => '11-03',
'Día de Colón' => '11-05',
'Grito de independencia de La Villa de Los Santos' => '11-10',
'Independencia de Panamá de España' => '11-25',
'Día de la Madre' => '12-08',
'Duelo Nacional por la Invasión de Estados Unidos a Panamá' => '12-20',
'Navidad' => '12-25',
], $this->variableHolidays($year));
}

/** @return array<string, CarbonImmutable> */
protected function variableHolidays(int $year): array
{
$easter = CarbonImmutable::createFromTimestamp(easter_date($year))
->setTimezone('America/Panama');

return [
'Jueves Santo' => $easter->subDays(3),
'Viernes Santo' => $easter->subDays(2),
'Sábado de Gloria' => $easter->subDays(1),
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
[
{
"name": "A\u00f1o Nuevo",
"date": "2024-01-01"
},
{
"name": "D\u00eda de los M\u00e1rtires",
"date": "2024-01-09"
},
{
"name": "Viernes Santo",
"date": "2024-03-28"
},
{
"name": "S\u00e1bado de Gloria",
"date": "2024-03-29"
},
{
"name": "D\u00eda del Trabajo",
"date": "2024-05-01"
},
{
"name": "Separación de Panamá de Colombia",
"date": "2024-11-03"
},
{
"name": "D\u00eda de Col\u00f3n",
"date": "2024-11-05"
},
{
"name": "Grito de independencia de La Villa de Los Santos",
"date": "2024-11-10"
},
{
"name": "Independencia de Panam\u00e1 de Espa\00f1a",
"date": "2024-11-28"
},
{
"name": "D\u00eda de la Madre",
"date": "2024-12-08"
},
{
"name": "Duelo Nacional por la Invasi\u00f3n de Estados Unidos a Panam\u00e1",
"date": "2024-12-20"
},
{
"name": "Navidad",
"date": "2024-12-25"
}
]
18 changes: 18 additions & 0 deletions tests/Countries/PanamaTest.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 panama holidays', function () {
CarbonImmutable::setTestNowAndTimezone('2024-01-01');

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

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

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