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.
- Loading branch information
1 parent
c73c665
commit 941fbfb
Showing
3 changed files
with
110 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,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, | ||
]; | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
tests/.pest/snapshots/Countries/AngolaTest/it_can_calculate_angola_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,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" | ||
} | ||
] |
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 angola holidays', function () { | ||
CarbonImmutable::setTestNowAndTimezone('2024-01-01'); | ||
|
||
$holidays = Holidays::for(country: 'ao')->get(); | ||
|
||
expect($holidays) | ||
->toBeArray() | ||
->not()->toBeEmpty(); | ||
|
||
expect(formatDates($holidays))->toMatchSnapshot(); | ||
}); |