Skip to content

Commit

Permalink
Add Angola Holidays (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
monteirofutila authored Jan 25, 2024
1 parent c73c665 commit 941fbfb
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/Countries/Angola.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace Spatie\Holidays\Countries;

use Carbon\CarbonImmutable;

class Angola extends Country
{
public function countryCode(): string
{
return 'ao';
}

protected function allHolidays(int $year): array
{

return array_merge([
'Dia de Ano Novo' => '01-01',
'Dia do Inicio da Luta Armada de Libertação Nacional' => '02-04',
'Dia Internacional da Mulher' => '03-08',
'Dia da Paz' => '04-04',
'Dia Internacional do Trabalhador' => '05-01',
'Dia do Fundador da Nação e do Herói Nacional' => '09-17',
'Dia dos Finados' => '11-02',
'Dia da Independência Nacional' => '11-11',
'Dia do Natal' => '12-25',
], $this->variableHolidays($year));
}

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

return [
'Carnaval' => $easter->subDays(47),
'Sexta Feira Santa' => $easter->subDays(2),
'Páscoa' => $easter,
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
[
{
"name": "Dia de Ano Novo",
"date": "2024-01-01"
},
{
"name": "Dia do Inicio da Luta Armada de Liberta\u00e7\u00e3o Nacional",
"date": "2024-02-04"
},
{
"name": "Carnaval",
"date": "2024-02-13"
},
{
"name": "Dia Internacional da Mulher",
"date": "2024-03-08"
},
{
"name": "Sexta Feira Santa",
"date": "2024-03-29"
},
{
"name": "P\u00e1scoa",
"date": "2024-03-31"
},
{
"name": "Dia da Paz",
"date": "2024-04-04"
},
{
"name": "Dia Internacional do Trabalhador",
"date": "2024-05-01"
},
{
"name": "Dia do Fundador da Na\u00e7\u00e3o e do Her\u00f3i Nacional",
"date": "2024-09-17"
},
{
"name": "Dia dos Finados",
"date": "2024-11-02"
},
{
"name": "Dia da Independ\u00eancia Nacional",
"date": "2024-11-11"
},
{
"name": "Dia do Natal",
"date": "2024-12-25"
}
]
18 changes: 18 additions & 0 deletions tests/Countries/AngolaTest.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 angola holidays', function () {
CarbonImmutable::setTestNowAndTimezone('2024-01-01');

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

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

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

0 comments on commit 941fbfb

Please sign in to comment.