generated from spatie/package-skeleton-php
-
-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/florinp/holidays
- Loading branch information
Showing
19 changed files
with
298 additions
and
39 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 |
---|---|---|
@@ -1,9 +1,6 @@ | ||
name: Fix PHP code style issues | ||
|
||
on: | ||
push: | ||
paths: | ||
- '**.php' | ||
on: [push] | ||
|
||
permissions: | ||
contents: write | ||
|
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
name: PHPStan | ||
|
||
on: [push] | ||
on: [push, pull_request] | ||
|
||
jobs: | ||
phpstan: | ||
|
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
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
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
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 Andorra extends Country | ||
{ | ||
public function countryCode(): string | ||
{ | ||
return 'ad'; | ||
} | ||
|
||
protected function allHolidays(int $year): array | ||
{ | ||
return array_merge([ | ||
'Any nou' => '01-01', | ||
'Reis' => '01-06', | ||
'Dia de la Constitució' => '03-14', | ||
'Festa del Treball' => '05-01', | ||
'Assumpció' => '08-15', | ||
'Mare de Déu de Meritxell' => '09-08', | ||
'Tots Sants' => '11-01', | ||
'Immaculada Concepció' => '11-08', | ||
'Nadal' => '12-25', | ||
'Sant Esteve' => '12-26', | ||
], $this->variableHolidays($year)); | ||
} | ||
|
||
/** @return array<string, CarbonImmutable> */ | ||
protected function variableHolidays(int $year): array | ||
{ | ||
$easter = CarbonImmutable::createFromTimestamp(easter_date($year)) | ||
->setTimezone('Europe/Brussels'); | ||
|
||
return [ | ||
'Divendres Sant' => $easter->subDays(2), | ||
'Dilluns de Pasqua' => $easter->addDay(), | ||
'Dilluns de Pentecosta' => $easter->addDays(50), | ||
]; | ||
} | ||
} |
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
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
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
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
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,46 @@ | ||
<?php | ||
|
||
namespace Spatie\Holidays\Countries; | ||
|
||
use Carbon\CarbonImmutable; | ||
|
||
class Denmark extends Country | ||
{ | ||
public function countryCode(): string | ||
{ | ||
return 'da'; | ||
} | ||
|
||
protected function allHolidays(int $year): array | ||
{ | ||
return array_merge([ | ||
'Nytår' => '01-01', | ||
'Juleaften' => '12-24', | ||
'Juledag' => '12-25', | ||
'Anden Juledag' => '12-26', | ||
], $this->variableHolidays($year)); | ||
} | ||
|
||
/** @return array<string, CarbonImmutable> */ | ||
protected function variableHolidays(int $year): array | ||
{ | ||
$easter = CarbonImmutable::createFromTimestamp(easter_date($year)) | ||
->setTimezone('Europe/Copenhagen'); | ||
|
||
$holidays = [ | ||
'Påskedag' => $easter->addDay(), | ||
'Skærtorsdag' => $easter->subDays(3), | ||
'Langfredag' => $easter->subDays(2), | ||
'Anden Påskedag' => $easter->addDays(2), | ||
'Kristi Himmelfartsdag' => $easter->addDays(39), | ||
'Pinse' => $easter->addDays(49), | ||
'Anden Pinsedag' => $easter->addDays(50), | ||
]; | ||
|
||
if ($year < 2024) { | ||
$holidays['Store Bededag'] = $easter->addDays(26); | ||
} | ||
|
||
return $holidays; | ||
} | ||
} |
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
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
54 changes: 54 additions & 0 deletions
54
tests/.pest/snapshots/Countries/AndorraTest/it_can_calculate_andorra_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,54 @@ | ||
[ | ||
{ | ||
"name": "Any nou", | ||
"date": "2024-01-01" | ||
}, | ||
{ | ||
"name": "Reis", | ||
"date": "2024-01-06" | ||
}, | ||
{ | ||
"name": "Dia de la Constituci\u00f3", | ||
"date": "2024-03-14" | ||
}, | ||
{ | ||
"name": "Divendres Sant", | ||
"date": "2024-03-29" | ||
}, | ||
{ | ||
"name": "Dilluns de Pasqua", | ||
"date": "2024-04-01" | ||
}, | ||
{ | ||
"name": "Festa del Treball", | ||
"date": "2024-05-01" | ||
}, | ||
{ | ||
"name": "Dilluns de Pentecosta", | ||
"date": "2024-05-20" | ||
}, | ||
{ | ||
"name": "Assumpci\u00f3", | ||
"date": "2024-08-15" | ||
}, | ||
{ | ||
"name": "Mare de D\u00e9u de Meritxell", | ||
"date": "2024-09-08" | ||
}, | ||
{ | ||
"name": "Tots Sants", | ||
"date": "2024-11-01" | ||
}, | ||
{ | ||
"name": "Immaculada Concepci\u00f3", | ||
"date": "2024-11-08" | ||
}, | ||
{ | ||
"name": "Nadal", | ||
"date": "2024-12-25" | ||
}, | ||
{ | ||
"name": "Sant Esteve", | ||
"date": "2024-12-26" | ||
} | ||
] |
Oops, something went wrong.