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 Chile Holidays #88

Merged
merged 3 commits into from
Jan 26, 2024
Merged
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
47 changes: 47 additions & 0 deletions src/Countries/Chile.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

namespace Spatie\Holidays\Countries;

use Carbon\CarbonImmutable;

class Chile extends Country
{
public function countryCode(): string
{
return 'cl';
}

protected function allHolidays(int $year): array
{
return [
'Año Nuevo' => '01-01',
'Viernes Santo' => '03-29',
'Sábado Santo' => '03-30',
'Día del Trabajador' => '05-01',
'Día de las Glorias Navales' => '05-21',
'Día Nacional de los Pueblos Indígenas' => '06-20',
'San Pedro y San Pablo' => '06-29',
'Día de la Virgen del Carmen' => '07-16',
'Asunción de la Virgen' => '08-15',
'Independencia Nacional' => '09-18',
'Día de las Glorias del Ejército' => '09-19',
'Feriado añadido de Fiestas Patrias' => '09-20',
'Encuentro de Dos Mundos' => '10-12',
'Día de las Iglesias Evangélicas' => '10-31',
'Día de Todos los Santos' => '11-01',
'Inmaculada Concepción' => '12-08',
'Navidad' => '12-25',
];
}

protected function variableHolidays(int $year): array

Check failure on line 37 in src/Countries/Chile.php

View workflow job for this annotation

GitHub Actions / phpstan

Method Spatie\Holidays\Countries\Chile::variableHolidays() return type has no value type specified in iterable type array.
{
$easter = CarbonImmutable::createFromTimestamp(easter_date($year))
->setTimezone('America/Santiago');

return [
'Jueves santo' => $easter->subDays(3),
'Viernes santo' => $easter->subDays(2),
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
[
{
"name": "A\u00f1o Nuevo",
"date": "2024-01-01"
},
{
"name": "Viernes Santo",
"date": "2024-03-29"
},
{
"name": "S\u00e1bado Santo",
"date": "2024-03-30"
},
{
"name": "D\u00eda del Trabajador",
"date": "2024-05-01"
},
{
"name": "D\u00eda de las Glorias Navales",
"date": "2024-05-21"
},
{
"name": "D\u00eda Nacional de los Pueblos Ind\u00edgenas",
"date": "2024-06-20"
},
{
"name": "San Pedro y San Pablo",
"date": "2024-06-29"
},
{
"name": "D\u00eda de la Virgen del Carmen",
"date": "2024-07-16"
},
{
"name": "Asunci\u00f3n de la Virgen",
"date": "2024-08-15"
},
{
"name": "Independencia Nacional",
"date": "2024-09-18"
},
{
"name": "D\u00eda de las Glorias del Ej\u00e9rcito",
"date": "2024-09-19"
},
{
"name": "Feriado a\u00f1adido de Fiestas Patrias",
"date": "2024-09-20"
},
{
"name": "Encuentro de Dos Mundos",
"date": "2024-10-12"
},
{
"name": "D\u00eda de las Iglesias Evang\u00e9licas",
"date": "2024-10-31"
},
{
"name": "D\u00eda de Todos los Santos",
"date": "2024-11-01"
},
{
"name": "Inmaculada Concepci\u00f3n",
"date": "2024-12-08"
},
{
"name": "Navidad",
"date": "2024-12-25"
}
]
18 changes: 18 additions & 0 deletions tests/Countries/ChileTest.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 chile holidays', function () {
CarbonImmutable::setTestNowAndTimezone('2024-01-01');

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

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

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