Skip to content

Commit

Permalink
Merge branch 'spatie:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
alvleont authored Jan 23, 2024
2 parents ad5460c + f9423cf commit 7191437
Show file tree
Hide file tree
Showing 76 changed files with 3,807 additions and 78 deletions.
49 changes: 49 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,55 @@

All notable changes to `holidays` will be documented in this file.

## 1.2.0 - 2024-01-23

### What's Changed

* Added Dominican Republic holidays by @KiritoXD01 in https://github.com/spatie/holidays/pull/57
* Added pint package by @thecaliskan in https://github.com/spatie/holidays/pull/149
* Polish holidays by @srsbiz in https://github.com/spatie/holidays/pull/154
* Add Support for Liechtenstein by @Martin-Welte in https://github.com/spatie/holidays/pull/33
* test: update liechtenstein snapshot by @Martin-Welte in https://github.com/spatie/holidays/pull/164
* Added Haiti holidays by @ivanmercedes in https://github.com/spatie/holidays/pull/148
* Add Romanian Holidays by @florinp in https://github.com/spatie/holidays/pull/27
* Add Guatemala holidays by @ejchiroy in https://github.com/spatie/holidays/pull/106
* Add holidays for Luxembourg by @UrbinCedric in https://github.com/spatie/holidays/pull/165
* Add holidays for South Africa by @pierredup in https://github.com/spatie/holidays/pull/30
* Add Peru holidays by @dlopez525 in https://github.com/spatie/holidays/pull/54
* Update Dutch holidays by @ndijkstra in https://github.com/spatie/holidays/pull/67
* Added historical data for Czechia by @inDeev in https://github.com/spatie/holidays/pull/159
* Add Greece holidays by @lowv-developer in https://github.com/spatie/holidays/pull/114
* Add 🇽🇰Kosovo🇽🇰 Holidays by @AvdylKrasniqi in https://github.com/spatie/holidays/pull/151
* Feature/add panama holidays by @amitsamtani in https://github.com/spatie/holidays/pull/147
* Add Norway Holidays by @Tor2r in https://github.com/spatie/holidays/pull/105
* Add Lithuanian holidays by @eimantaaas in https://github.com/spatie/holidays/pull/163
* Add Canadian Holidays by @thinkstylestudio in https://github.com/spatie/holidays/pull/41
* Add Turkmenistan Holidays by @kakajansh in https://github.com/spatie/holidays/pull/96

### New Contributors

* @KiritoXD01 made their first contribution in https://github.com/spatie/holidays/pull/57
* @thecaliskan made their first contribution in https://github.com/spatie/holidays/pull/149
* @srsbiz made their first contribution in https://github.com/spatie/holidays/pull/154
* @Martin-Welte made their first contribution in https://github.com/spatie/holidays/pull/33
* @ivanmercedes made their first contribution in https://github.com/spatie/holidays/pull/148
* @florinp made their first contribution in https://github.com/spatie/holidays/pull/27
* @ejchiroy made their first contribution in https://github.com/spatie/holidays/pull/106
* @UrbinCedric made their first contribution in https://github.com/spatie/holidays/pull/165
* @pierredup made their first contribution in https://github.com/spatie/holidays/pull/30
* @dlopez525 made their first contribution in https://github.com/spatie/holidays/pull/54
* @ndijkstra made their first contribution in https://github.com/spatie/holidays/pull/67
* @inDeev made their first contribution in https://github.com/spatie/holidays/pull/159
* @lowv-developer made their first contribution in https://github.com/spatie/holidays/pull/114
* @AvdylKrasniqi made their first contribution in https://github.com/spatie/holidays/pull/151
* @amitsamtani made their first contribution in https://github.com/spatie/holidays/pull/147
* @Tor2r made their first contribution in https://github.com/spatie/holidays/pull/105
* @eimantaaas made their first contribution in https://github.com/spatie/holidays/pull/163
* @thinkstylestudio made their first contribution in https://github.com/spatie/holidays/pull/41
* @kakajansh made their first contribution in https://github.com/spatie/holidays/pull/96

**Full Changelog**: https://github.com/spatie/holidays/compare/1.1.0...1.2.0

## 1.1.0 - 2024-01-19

### What's Changed
Expand Down
9 changes: 7 additions & 2 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,14 @@ parameters:
path: src/Countries/Country.php

-
message: "#^Cannot call method setTimezone\\(\\) on Carbon\\\\CarbonImmutable\\|false\\.$#"
message: "#^Cannot call method setTimeStamp\\(\\) on DateTime\\|false\\.$#"
count: 1
path: src/Countries/Mexico.php
path: src/Countries/Turkmenistan.php

-
message: "#^Parameter \\#1 \\$datetime of method IntlDateFormatter\\:\\:format\\(\\) expects array\\|DateTimeInterface\\|float\\|int\\|IntlCalendar\\|string, DateTime\\|false given\\.$#"
count: 1
path: src/Countries/Turkmenistan.php

-
message: "#^Parameter \\#1 \\$callback of function array_map expects \\(callable\\(Carbon\\\\CarbonImmutable\\)\\: mixed\\)\\|null, Closure\\(string\\)\\: non\\-falsy\\-string given\\.$#"
Expand Down
60 changes: 60 additions & 0 deletions src/Countries/Canada.php
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,
];
}
}
63 changes: 47 additions & 16 deletions src/Countries/Czechia.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,60 @@ public function countryCode(): string

protected function allHolidays(int $year): array
{
return array_merge([
'Den obnovy samostatného českého státu' => '01-01',
'Svátek práce' => '05-01',
'Den vítězství' => '05-08',
'Den slovanských věrozvěstů Cyrila a Metoděje' => '07-05',
'Den upálení mistra Jana Husa' => '07-06',
'Den české státnosti' => '09-28',
'Den vzniku samostatného československého státu' => '10-28',
'Den boje za svobodu a demokracii a Mezinárodní den studentstva' => '11-17',
'Štědrý den' => '12-24',
'1. svátek vánoční' => '12-25',
'2. svátek vánoční' => '12-26',
], $this->variableHolidays($year));
// https://kalendar.beda.cz/statni-svatky-a-vyznamne-dny-v-roce-prehledne?year=1970
$holidays = [
'Nový rok' => ['01-01', $year <= 2000],
'Nový rok; Den obnovy samostatného českého státu' => ['01-01', $year >= 2001],

'Svátek práce' => ['05-01', true],

'Výročí osvobození Československa Sovětskou armádou' => ['05-09', $year <= 1990],
'Den osvobození od fašismu' => [$year === 1991 ? '05-09' : '05-08', $year >= 1991 && $year <= 2000],
'Den osvobození' => ['05-08', $year >= 2001 && $year <= 2003],
'Den vítězství' => ['05-08', $year >= 2004],

'Den slovanských věrozvěstů Cyrila a Metoděje' => ['07-05', $year >= 1990],

'Den upálení mistra Jana Husa' => ['07-06', $year >= 1990],

'Den české státnosti' => ['09-28', $year >= 2000],

'Vyhlášení samostatnosti ČSR; Schválení zákona o federaci' => ['10-28', $year <= 1971],
'Den znárodnění' => ['10-28', $year === 1972],
'Vyhlášení samostatnosti ČSR; Schválení zákona o federaci; Den znárodnění' => ['10-28', $year >= 1973 && $year <= 1974],
'Den vzniku samostatného československého státu' => ['10-28', $year >= 1988],

'Den boje za svobodu a demokracii a Mezinárodní den studentstva' => ['11-17', $year >= 2000],
'Štědrý den' => ['12-24', $year >= 1990],
'1. svátek vánoční' => ['12-25', true],
'2. svátek vánoční' => ['12-26', true],
];

$filteredHolidays = array_map(
static fn (array $holiday) => $holiday[0],
array_filter($holidays,
static fn (array $holiday) => $holiday[1] === true
)
);

return array_merge($filteredHolidays, $this->variableHolidays($year));
}

/** @return array<string, CarbonImmutable> */
protected function variableHolidays(int $year): array
{
$easter = $this->easter($year);

return [
'Velikonoční pondělí' => $easter->addDay(),
'Velký pátek' => $easter->subDays(2),
$variableHolidays = [
'Velikonoční pondělí' => [$easter->addDay(), true],
'Velký pátek' => [$easter->subDays(2), $year >= 2016],
];

return array_map(
static fn (array $variableHoliday) => $variableHoliday[0],
array_filter($variableHolidays,
static fn (array $variableHoliday) => $variableHoliday[1] === true
)
);
}
}
60 changes: 60 additions & 0 deletions src/Countries/Greece.php
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
];
}
}
38 changes: 38 additions & 0 deletions src/Countries/Guatemala.php
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),
];
}
}
40 changes: 40 additions & 0 deletions src/Countries/Haiti.php
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),
];
}
}
42 changes: 42 additions & 0 deletions src/Countries/Kosovo.php
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;
}
}
Loading

0 comments on commit 7191437

Please sign in to comment.