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 'spatie:main' into main
- Loading branch information
Showing
76 changed files
with
3,807 additions
and
78 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
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,60 @@ | ||
<?php | ||
|
||
namespace Spatie\Holidays\Countries; | ||
|
||
use Carbon\CarbonImmutable; | ||
|
||
class Canada extends Country | ||
{ | ||
public function countryCode(): string | ||
{ | ||
return 'ca'; | ||
} | ||
|
||
protected function allHolidays(int $year): array | ||
{ | ||
return array_merge( | ||
[ | ||
'New Year\'s Day' => new CarbonImmutable($year.'-01-01', 'America/Toronto'), | ||
'Canada Day' => new CarbonImmutable($year.'-07-01', 'America/Toronto'), | ||
'Civic Holiday' => new CarbonImmutable( | ||
'first monday of August '.$year, 'America/Toronto' | ||
), | ||
'Labour Day' => new CarbonImmutable( | ||
'first monday of September '.$year, 'America/Toronto' | ||
), | ||
'National Day for Truth and Reconciliation' => new CarbonImmutable( | ||
$year.'-09-30', | ||
'America/Toronto' | ||
), | ||
'Remembrance Day' => new CarbonImmutable($year.'-11-11', 'America/Toronto'), | ||
'Christmas Day' => new CarbonImmutable($year.'-12-25', 'America/Toronto'), | ||
'Boxing Day' => new CarbonImmutable($year.'-12-26', 'America/Toronto'), | ||
], | ||
$this->variableHolidays($year) | ||
); | ||
} | ||
|
||
/** @return array<string, CarbonImmutable> */ | ||
protected function variableHolidays(int $year): array | ||
{ | ||
$easter = $this->easter($year); | ||
|
||
$goodFriday = $easter->subDays(2); | ||
$easterMonday = $easter->addDay(); | ||
|
||
$victoriaDay = new CarbonImmutable("last monday of May $year", 'America/Toronto'); | ||
if ($victoriaDay->day < 25) { | ||
$victoriaDay = $victoriaDay->addWeek(); | ||
} | ||
|
||
$thanksgiving = new CarbonImmutable("second monday of October $year", 'America/Toronto'); | ||
|
||
return [ | ||
'Victoria Day' => $victoriaDay, | ||
'Good Friday' => $goodFriday, | ||
'Easter Monday' => $easterMonday, | ||
'Thanksgiving' => $thanksgiving, | ||
]; | ||
} | ||
} |
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,60 @@ | ||
<?php | ||
|
||
namespace Spatie\Holidays\Countries; | ||
|
||
use Carbon\CarbonImmutable; | ||
|
||
class Greece extends Country | ||
{ | ||
public function countryCode(): string | ||
{ | ||
return 'el'; | ||
} | ||
|
||
protected function allHolidays(int $year): array | ||
{ | ||
return array_merge([ | ||
'Πρωτοχρονιά' => '01-01', | ||
'Θεοφάνια' => '01-06', | ||
'25η Μαρτίου' => '03-25', | ||
'Πρωτομαγιά' => '05-01', | ||
'Δεκαπενταύγουστος' => '08-15', | ||
'28η Οκτωβρίου' => '10-28', | ||
'Χριστούγεννα' => '12-25', | ||
'Σύναξη της Θεοτόκου' => '12-26', | ||
|
||
], $this->variableHolidays($year)); | ||
} | ||
|
||
/** @return array<string, CarbonImmutable> */ | ||
protected function variableHolidays(int $year): array | ||
{ | ||
// OrthodoxEaster needs to setTimezone | ||
$orthodoxEaster = $this->orthodoxEaster($year)->setTimezone('Europe/Athens'); | ||
$cleanMonday = $orthodoxEaster->copy()->subDays(48); | ||
$megaliParaskevi = $orthodoxEaster->copy()->subDays(2); | ||
$megaloSavvato = $orthodoxEaster->copy()->subDays(1); | ||
$deuteraPasha = $orthodoxEaster->copy()->addDay(); | ||
$agiouPneumatos = $orthodoxEaster->copy()->addDays(50); | ||
|
||
/** @var CarbonImmutable $protomagia */ | ||
$protomagia = CarbonImmutable::createFromFormat('Y-m-d', "{$year}-05-01"); | ||
$moveProtomagia = [$megaliParaskevi, $megaloSavvato, $orthodoxEaster, $deuteraPasha]; | ||
|
||
if (in_array($protomagia, $moveProtomagia)) { | ||
$protomagia = $orthodoxEaster->copy()->addDays(2); | ||
} | ||
if ($protomagia->isSunday()) { | ||
$protomagia = $protomagia->copy()->addDay(); | ||
} | ||
|
||
return [ | ||
'Καθαρά Δευτέρα' => $cleanMonday, //always Monday | ||
'Πρωτομαγιά' => $protomagia, | ||
'Μεγάλη Παρασκευή' => $megaliParaskevi, | ||
'Κυριακή του Πάσχα' => $orthodoxEaster, | ||
'Δευτέρα του Πάσχα' => $deuteraPasha, | ||
'Αγίου Πνεύματος' => $agiouPneumatos, //always Monday | ||
]; | ||
} | ||
} |
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,38 @@ | ||
<?php | ||
|
||
namespace Spatie\Holidays\Countries; | ||
|
||
use Carbon\CarbonImmutable; | ||
|
||
class Guatemala extends Country | ||
{ | ||
public function countryCode(): string | ||
{ | ||
return 'gt'; | ||
} | ||
|
||
protected function allHolidays(int $year): array | ||
{ | ||
return array_merge([ | ||
'Año Nuevo' => '01-01', | ||
'Día de los Trabajadores' => '05-01', | ||
'Día del Ejército' => '06-31', | ||
'Día de la Independencia' => '09-15', | ||
'Día de la Revolución' => '10-20', | ||
'Día de Todos los Santos' => '11-01', | ||
'Navidad' => '12-25', | ||
], $this->variableHolidays($year)); | ||
} | ||
|
||
/** @return array<string, CarbonImmutable> */ | ||
protected function variableHolidays(int $year): array | ||
{ | ||
$easter = $this->easter($year); | ||
|
||
return [ | ||
'Jueves Santo' => $easter->subDays(3), | ||
'Viernes Santo' => $easter->subDays(2), | ||
'Sábado Santo' => $easter->subDays(1), | ||
]; | ||
} | ||
} |
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,40 @@ | ||
<?php | ||
|
||
namespace Spatie\Holidays\Countries; | ||
|
||
use Carbon\CarbonImmutable; | ||
|
||
class Haiti extends Country | ||
{ | ||
public function countryCode(): string | ||
{ | ||
return 'ht'; | ||
} | ||
|
||
protected function allHolidays(int $year): array | ||
{ | ||
return array_merge([ | ||
'Nouvel an / Jour de l\'Indépendance' => '01-01', | ||
'Jour des Aieux' => '01-2', | ||
'Fête du Travail / Fête des Travailleurs' => '05-01', | ||
'Jour du Drapeau et de l\'Université' => '05-18', | ||
'L\'Assomption de Marie' => '08-15', | ||
'Anniversaire de la mort de Dessalines' => '10-17', | ||
'Toussaint' => '11-01', | ||
'Jour des Morts' => '11-02', | ||
'Vertières' => '11-18', | ||
'Noël' => '12-25', | ||
], $this->variableHolidays($year)); | ||
} | ||
|
||
/** @return array<string, CarbonImmutable> */ | ||
protected function variableHolidays(int $year): array | ||
{ | ||
$easter = $this->easter($year); | ||
|
||
return [ | ||
'Carnaval/Mardi Gras' => $easter->subDays(47), | ||
'Vendredi saint' => $easter->subDays(2), | ||
]; | ||
} | ||
} |
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 Kosovo extends Country | ||
{ | ||
public function countryCode(): string | ||
{ | ||
return 'xk'; | ||
} | ||
|
||
protected function allHolidays(int $year): array | ||
{ | ||
return array_merge([ | ||
'Viti i Ri' => '01-01', | ||
'Krishtlindjet ortodokse' => '01-07', | ||
'Dita Ndërkombëtare e Punës' => '05-01', | ||
'Dita e Evropës' => '05-09', | ||
'Krishtlindjet Katolike' => '12-25', | ||
], $this->variableHolidays($year)); | ||
} | ||
|
||
/** @return array<string, CarbonImmutable|string> */ | ||
protected function variableHolidays(int $year): array | ||
{ | ||
$holidays = []; | ||
|
||
$holidays['Pashkët Katolike'] = $this->easter($year); | ||
$holidays['Pashkët Ortodokse'] = $this->orthodoxEaster($year); | ||
|
||
if ($year >= 2008) { | ||
$holidays['Dita e Pavarësisë së Republikës së Kosovës'] = '02-17'; | ||
$holidays['Dita e Kushtetutës së Republikës së Kosovës'] = '04-09'; | ||
} | ||
|
||
// TODO: Implement islamic holidays | ||
|
||
return $holidays; | ||
} | ||
} |
Oops, something went wrong.