Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
inDeev authored Jan 25, 2024
2 parents 447203b + b5bb47f commit a6f4467
Show file tree
Hide file tree
Showing 188 changed files with 7,449 additions and 139 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/fix-php-code-style-issues.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Fix PHP code style issues

on: [push]
on: [push, pull_request]

permissions:
contents: write
Expand Down
89 changes: 89 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,95 @@

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

## 1.3.0 - 2024-01-25

### What's Changed

* Add Ukrainian holidays by @kapi14 in https://github.com/spatie/holidays/pull/112
* Added Turkey holidays by @thecaliskan in https://github.com/spatie/holidays/pull/70
* Added has helper by @thecaliskan in https://github.com/spatie/holidays/pull/170
* Add Slovakia holidays by @patressz in https://github.com/spatie/holidays/pull/102
* Add support for multi languages by @Nielsvanpach in https://github.com/spatie/holidays/pull/177
* Add latvian holidays by @IvarsSaudinis in https://github.com/spatie/holidays/pull/169
* Added Colombia Holidays by @alvleont in https://github.com/spatie/holidays/pull/55
* Add Finnish Holidays by @ConnySjoblom in https://github.com/spatie/holidays/pull/85
* Add Japan support by @mkokio in https://github.com/spatie/holidays/pull/160
* Add United States Holidays by @arcdigital in https://github.com/spatie/holidays/pull/26
* Add Serbian holidays by @knubbe82 in https://github.com/spatie/holidays/pull/107
* Add El Salvador Holidays by @vlltr in https://github.com/spatie/holidays/pull/93
* Belarus Holidays by @Jampire in https://github.com/spatie/holidays/pull/156
* Adding German holidays by @arnebr in https://github.com/spatie/holidays/pull/8
* Add Australian Holidays by @patrickomeara in https://github.com/spatie/holidays/pull/43
* Update Australia.php by @OnyileFelix1 in https://github.com/spatie/holidays/pull/178
* Bug fix: calculating orthodox easter by @Nielsvanpach in https://github.com/spatie/holidays/pull/180

### New Contributors

* @kapi14 made their first contribution in https://github.com/spatie/holidays/pull/112
* @patressz made their first contribution in https://github.com/spatie/holidays/pull/102
* @IvarsSaudinis made their first contribution in https://github.com/spatie/holidays/pull/169
* @alvleont made their first contribution in https://github.com/spatie/holidays/pull/55
* @ConnySjoblom made their first contribution in https://github.com/spatie/holidays/pull/85
* @mkokio made their first contribution in https://github.com/spatie/holidays/pull/160
* @arcdigital made their first contribution in https://github.com/spatie/holidays/pull/26
* @knubbe82 made their first contribution in https://github.com/spatie/holidays/pull/107
* @vlltr made their first contribution in https://github.com/spatie/holidays/pull/93
* @Jampire made their first contribution in https://github.com/spatie/holidays/pull/156
* @arnebr made their first contribution in https://github.com/spatie/holidays/pull/8
* @patrickomeara made their first contribution in https://github.com/spatie/holidays/pull/43
* @OnyileFelix1 made their first contribution in https://github.com/spatie/holidays/pull/178

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

## 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
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ use Spatie\Holidays\Holidays;
$holidays = Holidays::for('be')->getInRange('2023-06-01', '2024-05-31');
```

### Getting holidays in a specific language

```php
$holidays = Holidays::for(country: 'be', locale: 'fr'))->get();
```

If the locale is not supported for a country, an exception will be thrown.

### Determining if a date is a holiday

If you need to see if a date is a holiday, you can use the `isHoliday` method.
Expand All @@ -98,6 +106,17 @@ use Spatie\Holidays\Holidays;
Holidays::for('be')->getName('2024-01-01'); // Nieuwjaar
```

### Determining whether a country is supported

To verify whether a country is supported, you can use the `has` method.

```php
use Spatie\Holidays\Holidays;

Holidays::has('be'); // true
Holidays::has('unknown'); // false
```

### Package limitations
1. Islamic holidays are not supported (yet)

Expand All @@ -111,6 +130,7 @@ This is a community driven package. If you find any errors, please create an iss
2. Add a test for the new country in the `tests` directory.
3. Run the tests so a snapshot gets created.
4. Verify the result in the newly created snapshot is correct.
5. If the country has multiple languages, add a file in the `lang/` directory.

In case your country has specific rules for calculating holidays,
for example region specific holidays, you can pass this to the constructor of your country class.
Expand Down
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@
"ext-calendar": "*"
},
"require-dev": {
"laravel/pint": "^1.0",
"laravel/prompts": "^0.1.15",
"pestphp/pest": "^2.31",
"phpstan/phpstan": "^1.10.56",
"spatie/invade": "^2.0",
"spatie/ray": "^1.40.1",
"symfony/var-dumper": "^6.4"
},
Expand All @@ -46,7 +48,7 @@
"baseline": "vendor/bin/phpstan analyse --generate-baseline",
"test": "vendor/bin/pest",
"test-coverage": "vendor/bin/pest --coverage",
"format": "vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php --allow-risky=yes"
"format": "vendor/bin/pint"
},
"config": {
"sort-packages": true,
Expand Down
12 changes: 12 additions & 0 deletions lang/belarus/be-latn/holidays.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"Новы год": "Novy hod",
"Новы год (другі дзень)": "Novy hod (druhi dzień)",
"Нараджэнне Хрыстова (праваслаўнае Раство)": "Naradžeńnie Chrystova (pravasłaŭnaje Rastvo)",
"Дзень жанчын": "Dzień žančyn",
"Свята працы": "Sviata pracy",
"Дзень Перамогі": "Dzień Pieramohi",
"Дзень Незалежнасці": "Dzień Niezaležnaści",
"Дзень Кастрычніцкай рэвалюцыі": "Dzień Kastryčnickaj revalucyi",
"Нараджэнне Хрыстова (каталіцкае Раство)": "Naradžeńnie Chrystova (katalickaje Rastvo)",
"Радаўніца": "Radaŭnica"
}
12 changes: 12 additions & 0 deletions lang/belarus/en/holidays.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"Новы год": "New Year's Day",
"Новы год (другі дзень)": "New Year's Day (second day)",
"Нараджэнне Хрыстова (праваслаўнае Раство)": "Orthodox Christmas",
"Дзень жанчын": "Women's Day",
"Свята працы": "Labor Day",
"Дзень Перамогі": "Victory Day",
"Дзень Незалежнасці": "Independence Day",
"Дзень Кастрычніцкай рэвалюцыі": "October Revolution Day",
"Нараджэнне Хрыстова (каталіцкае Раство)": "Catholic Christmas",
"Радаўніца": "Radaunitsa"
}
12 changes: 12 additions & 0 deletions lang/belarus/ru/holidays.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"Новы год": "Новый год",
"Новы год (другі дзень)": "Новый год (второй день)",
"Нараджэнне Хрыстова (праваслаўнае Раство)": "Православное Рождество",
"Дзень жанчын": "Международный женский день",
"Свята працы": "День труда",
"Дзень Перамогі": "День Победы",
"Дзень Незалежнасці": "День Независимости",
"Дзень Кастрычніцкай рэвалюцыі": "День Октябрьской революции",
"Нараджэнне Хрыстова (каталіцкае Раство)": "Католическое Рождество",
"Радаўніца": "Радуница"
}
12 changes: 12 additions & 0 deletions lang/belgium/fr/holidays.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"Nieuwjaar": "Jour de l'An",
"Dag van de Arbeid": "Fête du Travail",
"Nationale Feestdag": "Fête nationale",
"OLV Hemelvaart": "Assomption",
"Allerheiligen": "Toussaint",
"Wapenstilstand": "Armistice",
"Kerstmis": "Noël",
"Paasmaandag": "Lundi de Pâques",
"OLH Hemelvaart": "Ascension",
"Pinkstermaandag": "Lundi de Pentecôte"
}
15 changes: 15 additions & 0 deletions lang/finland/sv/holidays.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"Uudenvuodenpäivä": "Nyårsdagen",
"Loppiainen": "Trettondagen",
"Pitkäperjantai": "Långfredagen",
"Pääsiäispäivä": "Påskdagen",
"Toinen pääsiäispäivä": "Annandag påsk",
"Vappu": "Första maj",
"Helatorstai": "Kristi himmelsfärdsdag",
"Helluntaipäivä": "Pingst",
"Juhannuspäivä": "Midsommardagen",
"Pyhäinpäivä": "Alla helgons dag",
"Itsenäisyyspäivä": "Självständighetsdagen",
"Joulupäivä": "Juldagen",
"Tapaninpäivä": "Annandag jul"
}
18 changes: 18 additions & 0 deletions lang/montenegro/en/holidays.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"Nova godina - prvi dan": "New Year - first day",
"Nova godina - drugi dan": "New Year - second day",
"Badnji dan": "Christmas Eve",
"Božić - prvi dan": "Christmas - first day",
"Božić - drugi dan": "Christmas - second day",
"Praznik rada - prvi dan": "Labour Day - first day",
"Praznik rada - drugi dan": "Labour Day - second day",
"Veliki petak": "Good Friday",
"Vaskrs": "Easter",
"Vaskršnji ponedjeljak": "Easter Monday",
"Dan nezavisnosti - prvi dan": "Independence Day - first day",
"Dan nezavisnosti - drugi dan": "Independence Day - second day",
"Dan državnosti - prvi dan": "National Day - first day",
"Dan državnosti - drugi dan": "National Day - second day",
"Njegošev dan - prvi dan": "Njegoš's Day - first day",
"Njegošev dan - drugi dan": "Njegoš's Day - second day"
}
18 changes: 18 additions & 0 deletions lang/montenegro/sr/holidays.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"Nova godina - prvi dan": "Nova godina - prvi dan",
"Nova godina - drugi dan": "Nova godina - drugi dan",
"Badnji dan": "Badnji dan",
"Božić - prvi dan": "Božić - prvi dan",
"Božić - drugi dan": "Božić - drugi dan",
"Praznik rada - prvi dan": "Praznik rada - prvi dan",
"Praznik rada - drugi dan": "Praznik rada - drugi dan",
"Veliki petak": "Veliki petak",
"Vaskrs": "Vaskrs",
"Vaskršnji ponedjeljak": "Vaskršnji ponedeljak",
"Dan nezavisnosti - prvi dan": "Dan nezavisnosti - prvi dan",
"Dan nezavisnosti - drugi dan": "Dan nezavisnosti - drugi dan",
"Dan državnosti - prvi dan": "Dan državnosti - prvi dan",
"Dan državnosti - drugi dan": "Dan državnosti - drugi dan",
"Njegošev dan - prvi dan": "Njegošev dan - prvi dan",
"Njegošev dan - drugi dan": "Njegošev dan - drugi dan"
}
30 changes: 10 additions & 20 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
parameters:
ignoreErrors:
-
message: "#^Argument of an invalid type array\\<int, string\\>\\|false supplied for foreach, only iterables are supported\\.$#"
message: "#^Cannot call method modify\\(\\) on Carbon\\\\CarbonImmutable\\|false\\.$#"
count: 1
path: src/Countries/Country.php
path: src/Countries/Australia.php

-
message: "#^Cannot call method startOfDay\\(\\) on Carbon\\\\CarbonImmutable\\|false\\.$#"
message: "#^Argument of an invalid type array\\<int, string\\>\\|false supplied for foreach, only iterables are supported\\.$#"
count: 1
path: src/Countries/Country.php

-
message: "#^Method Spatie\\\\Holidays\\\\Countries\\\\Country\\:\\:get\\(\\) should return array\\<string, Carbon\\\\CarbonImmutable\\|string\\> but returns array\\<string, Carbon\\\\CarbonImmutable\\|false\\>\\.$#"
count: 1
message: "#^Cannot call method startOfDay\\(\\) on Carbon\\\\CarbonImmutable\\|false\\.$#"
count: 2
path: src/Countries/Country.php

-
message: "#^Parameter \\#1 \\$timestamp of static method Carbon\\\\CarbonImmutable\\:\\:createFromTimestamp\\(\\) expects float\\|int\\|string, int\\|false given\\.$#"
message: "#^Method Spatie\\\\Holidays\\\\Countries\\\\Country\\:\\:get\\(\\) should return array\\<string, Carbon\\\\CarbonImmutable\\|string\\> but returns array\\<string, Carbon\\\\CarbonImmutable\\|false\\>\\.$#"
count: 1
path: src/Countries/Country.php

Expand All @@ -26,24 +26,14 @@ parameters:
path: src/Countries/Country.php

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

-
message: "#^Cannot call method isSunday\\(\\) on Carbon\\\\CarbonImmutable\\|false\\.$#"
count: 1
path: src/Countries/Netherlands.php

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

-
message: "#^Method Spatie\\\\Holidays\\\\Countries\\\\Netherlands\\:\\:variableHolidays\\(\\) should return array\\<string, Carbon\\\\CarbonImmutable\\> but returns array\\<string, Carbon\\\\CarbonImmutable\\|false\\>\\.$#"
message: "#^Parameter \\#1 \\$datetime of method IntlDateFormatter\\:\\:format\\(\\) expects array\\|DateTimeInterface\\|float\\|int\\|IntlCalendar\\|string, DateTime\\|false given\\.$#"
count: 1
path: src/Countries/Netherlands.php
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
37 changes: 37 additions & 0 deletions src/Concerns/Translatable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace Spatie\Holidays\Concerns;

use Spatie\Holidays\Exceptions\InvalidLocale;

trait Translatable
{
protected function translate(string $country, string $name, ?string $locale = null): string
{
if ($locale === null) {
return $name;
}

$countryName = strtolower($country);
$filePath = __DIR__."/../../lang/{$countryName}/{$locale}/holidays.json";

if (file_exists($filePath)) {
$content = file_get_contents($filePath);
} else {
throw InvalidLocale::notFound($country, $locale);
}

if ($content === false) {
throw InvalidLocale::notFound($country, $locale);
}

/** @var array<string, string> $data */
$data = json_decode($content, true);

if (! isset($data[$name])) {
return $name;
}

return $data[$name];
}
}
Loading

0 comments on commit a6f4467

Please sign in to comment.