Skip to content

Commit

Permalink
Merge branch 'main' into add-indian-holidays
Browse files Browse the repository at this point in the history
  • Loading branch information
webmavensteam authored May 2, 2024
2 parents 5acf662 + b7ef716 commit 643f10d
Show file tree
Hide file tree
Showing 14 changed files with 331 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dependabot-auto-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v2.0.0
uses: dependabot/fetch-metadata@v2.1.0
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
os: [ubuntu-latest]
php: [8.3, 8.2, 8.1]
stability: [prefer-lowest, prefer-stable]
carbon: [2.72, 3.0]
carbon: [2.72, 3.2]

name: P${{ matrix.php }} - ${{ matrix.stability }} - Carbon ${{ matrix.carbon }}

Expand Down
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@

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

## 1.10.0 - 2024-04-29

### What's Changed

* add Tunisia Holidays by @mr-wolf-gb in https://github.com/spatie/holidays/pull/109
* Add holidays for Ecuador by @insoutt in https://github.com/spatie/holidays/pull/218
* Bump aglipanci/laravel-pint-action from 2.3.1 to 2.4 by @dependabot in https://github.com/spatie/holidays/pull/221
* feat: remove canceled day of the rest from `Slovakia` country by @patressz in https://github.com/spatie/holidays/pull/223

### New Contributors

* @mr-wolf-gb made their first contribution in https://github.com/spatie/holidays/pull/109
* @insoutt made their first contribution in https://github.com/spatie/holidays/pull/218

**Full Changelog**: https://github.com/spatie/holidays/compare/1.9.1...1.10.0

## 1.9.1 - 2024-04-02

### What's Changed
Expand Down
25 changes: 25 additions & 0 deletions lang/bosnia-and-herzegovina/en/holidays.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"Nova godina - prvi dan": "New Year - first day",
"Nova godina - drugi dan": "New Year - second day",
"Badnji dan (za pravoslavce)": "Christmas Eve (Orthodox)",
"Božić (za pravoslavce)": "Christmas (Orthodox)",
"Badnji dan (za rimokatolike)": "Christmas Eve (Catholic)",
"Božić (za rimokatolike)": "Christmas (Catholic)",
"Praznik rada - prvi dan": "Labour Day - first day",
"Praznik rada - drugi dan": "Labour Day - second day",
"Veliki petak (za pravoslavce)": "Good Friday (Orthodox)",
"Veliki petak (za rimokatolike)": "Good Friday (Catholic)",
"Vaskrs (za pravoslavce)": "Easter (Orthodox)",
"Vaskrs (za rimokatolike)": "Easter (Catholic)",
"Vaskršnji ponedjeljak (za pravoslavce)": "Easter Monday (Orthodox)",
"Vaskršnji ponedjeljak (za rimokatolike)": "Easter Monday (Catholic)",

"Dan Republike": "Republic Day",
"Dan pobjede nad fašizmom": "The day of victory over fascism",
"Dan uspostavljanja Opšteg okvirnog sporazuma za mir u BiH": "The day of establishment of the General Framework Agreement for Peace in Bosnia and Herzegovina",

"Dan nezavisnosti Bosne i Hercegovine": "Independence Day of Bosnia And Herzegovina",
"Dan državnosti Bosne i Hercegovine": "National Day of Bosnia And Herzegovina",

"Dan uspostavljanja Brčko distrikta": "Day of establishment of Brčko District"
}
14 changes: 13 additions & 1 deletion src/Concerns/Translatable.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ public function translate(string $country, string $name, ?string $locale = null)

$locale = $locale ?? $this->defaultLocale();

$countryName = strtolower($country);
$countryName = $this->toHyphenSeparated($country);

$filePath = __DIR__."/../../lang/{$countryName}/{$locale}/holidays.json";

if (file_exists($filePath)) {
Expand All @@ -32,4 +33,15 @@ public function translate(string $country, string $name, ?string $locale = null)

return $data[$name] ?? $name;
}

protected function toHyphenSeparated(string $text): string
{
$toHyphens = preg_replace('/(?<=\\w)(?=[A-Z])/', '-$1', $text);

if ($toHyphens === null) {
return strtolower($text);
}

return strtolower($toHyphens);
}
}
22 changes: 10 additions & 12 deletions src/Countries/Ecuador.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Spatie\Holidays\Countries;

use Carbon\CarbonImmutable;
use Carbon\CarbonInterface;
use Spatie\Holidays\Concerns\Observable;
use Spatie\Holidays\Concerns\Translatable;
use Spatie\Holidays\Contracts\HasTranslations;
Expand All @@ -29,7 +30,7 @@ protected function allHolidays(int $year): array
], $this->variableHolidays($year));
}

public function nearestDay(int $year, int $month, int $day): CarbonImmutable
public function nearestDay(int $year, int $month, int $day): CarbonInterface
{
$date = CarbonImmutable::createFromDate($year, $month, $day);

Expand All @@ -41,29 +42,26 @@ public function nearestDay(int $year, int $month, int $day): CarbonImmutable
return $date->addDay();
}

if ($date->is('Wednesday')) {
return $date->addDays(2);
}

if ($date->is('Thursday')) {
return $date->addDay();
if ($date->is('Wednesday') || $date->is('Thursday')) {
return $date->next(CarbonInterface::FRIDAY);
}

return $date;
}

public function getChristmasHoliday(int $year): CarbonImmutable
public function getChristmasHoliday(int $year): CarbonInterface
{
if ($year === 2022) {
$date = $this->sundayToNextMonday('12-25', $year);
if ($date !== null) {
return CarbonImmutable::instance($date);
$observedChristmasDay = $this->sundayToNextMonday('12-25', $year);

if ($observedChristmasDay !== null) {
return $observedChristmasDay;
}
}
return CarbonImmutable::createFromDate($year, 12, 25);
}

/** @return array<string, CarbonImmutable> */
/** @return array<string, CarbonInterface> */
protected function variableHolidays(int $year): array
{
$easter = $this->easter($year);
Expand Down
11 changes: 6 additions & 5 deletions src/Countries/Greece.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,17 @@ protected function allHolidays(int $year): array
/** @return array<string, CarbonImmutable> */
protected function variableHolidays(int $year): array
{
$orthodoxEaster = $this->orthodoxEaster($year);

$orthodoxEaster = $this->orthodoxEaster($year);
$megaliTetarti = $orthodoxEaster->copy()->subDays(4);
$megaliPempti = $orthodoxEaster->copy()->subDays(3);
$megaliParaskevi = $orthodoxEaster->copy()->subDays(2);
$megaloSavvato = $orthodoxEaster->copy()->subDay();
$deuteraPasha = $orthodoxEaster->copy()->addDay();
$protomagia = CarbonImmutable::createFromDate($year, 5, 1)->startOfDay();

$protomagia = CarbonImmutable::createFromDate($year, 5, 1);
$moveProtomagia = [$megaliParaskevi, $megaloSavvato, $orthodoxEaster, $deuteraPasha];

if (in_array($protomagia, $moveProtomagia, true)) {
$moveProtomagia = [$megaliTetarti, $megaliPempti, $megaliParaskevi, $megaloSavvato, $orthodoxEaster, $deuteraPasha];
if (in_array($protomagia, $moveProtomagia)) {
$protomagia = $orthodoxEaster->copy()->addDays(2);
}

Expand Down
76 changes: 76 additions & 0 deletions src/Countries/Korea.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?php

namespace Spatie\Holidays\Countries;

use Carbon\CarbonImmutable;
use Spatie\Holidays\Calendars\ChineseCalendar;

class Korea extends Country
{
use ChineseCalendar;

public function countryCode(): string
{
return 'kr';
}

protected function allHolidays(int $year): array
{
return array_merge([
'신정' => '01-01',
'3ㆍ1절' => '03-01',
'어린이날' => '05-05',
'현충일' => '06-06',
'광복절' => '08-15',
'개천절' => '10-03',
'한글날' => '10-09',
'크리스마스' => '12-15',
], $this->variableHolidays($year));
}

/** @return array<string, CarbonImmutable> */
protected function variableHolidays(int $year): array
{
$this->setChineseCalendarTimezone('Asia/Seoul');

return array_merge(
$this->getLunarNewYearHoliday($year),
$this->getLunarBuddhasBirthday($year),
$this->getLunarChuseok($year),
);
}

/** @return array<string, CarbonImmutable> */
protected function getLunarNewYearHoliday(int $year): array
{
$firstOfJanInChineseCalendar = $this->chineseToGregorianDate('01-01', $year);

return [
'설날 연휴 1' => $firstOfJanInChineseCalendar->subDay(),
'설날' => $firstOfJanInChineseCalendar,
'설날 연휴 2' => $firstOfJanInChineseCalendar->addDay(),
];
}

/** @return array<string, CarbonImmutable> */
protected function getLunarBuddhasBirthday(int $year): array
{
$BuddhasBirthdayInChineseCalendar = $this->chineseToGregorianDate('04-08', $year);

return [
'부처님 오신날' => $BuddhasBirthdayInChineseCalendar,
];
}

/** @return array<string, CarbonImmutable> */
protected function getLunarChuseok(int $year): array
{
$chuseokInChineseCalendar = $this->chineseToGregorianDate('08-15', $year);

return [
'추석 연휴 1' => $chuseokInChineseCalendar->subDay(),
'추석' => $chuseokInChineseCalendar,
'추석 연휴 2' => $chuseokInChineseCalendar->addDay(),
];
}
}
1 change: 0 additions & 1 deletion src/Countries/Slovakia.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ protected function allHolidays(int $year): array
'Deň víťazstva nad fašizmom' => '05-08',
'Sviatok svätého Cyrila a Metoda' => '07-05',
'Výročie Slovenského národného povstania' => '08-29',
'Deň Ústavy Slovenskej republiky' => '09-01',
'Sedembolestná Panna Mária' => '09-15',
'Sviatok všetkých svätých' => '11-01',
'Deň boja za slobodu a demokraciu' => '11-17',
Expand Down
4 changes: 2 additions & 2 deletions src/Countries/Sweden.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ protected function allHolidays(int $year): array
return array_merge([
'Nyårsdagen' => '01-01',
'Trettondedag jul' => '01-06',
'Första maj' => '05-1',
'Nationaldagen' => '06-6',
'Första maj' => '05-01',
'Nationaldagen' => '06-06',
'Juldagen' => '12-25',
'Annandag jul' => '12-26',
], $this->variableHolidays($year));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
"name": "25\u03b7 \u039c\u03b1\u03c1\u03c4\u03af\u03bf\u03c5",
"date": "2024-03-25"
},
{
"name": "\u03a0\u03c1\u03c9\u03c4\u03bf\u03bc\u03b1\u03b3\u03b9\u03ac",
"date": "2024-05-01"
},
{
"name": "\u039c\u03b5\u03b3\u03ac\u03bb\u03b7 \u03a0\u03b1\u03c1\u03b1\u03c3\u03ba\u03b5\u03c5\u03ae",
"date": "2024-05-03"
Expand All @@ -31,6 +27,10 @@
"name": "\u0394\u03b5\u03c5\u03c4\u03ad\u03c1\u03b1 \u03c4\u03bf\u03c5 \u03a0\u03ac\u03c3\u03c7\u03b1",
"date": "2024-05-06"
},
{
"name": "\u03a0\u03c1\u03c9\u03c4\u03bf\u03bc\u03b1\u03b3\u03b9\u03ac",
"date": "2024-05-07"
},
{
"name": "\u0391\u03b3\u03af\u03bf\u03c5 \u03a0\u03bd\u03b5\u03cd\u03bc\u03b1\u03c4\u03bf\u03c2",
"date": "2024-06-24"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
[
{
"name": "\uc2e0\uc815",
"date": "2024-01-01"
},
{
"name": "\uc124\ub0a0 \uc5f0\ud734 1",
"date": "2024-02-09"
},
{
"name": "\uc124\ub0a0",
"date": "2024-02-10"
},
{
"name": "\uc124\ub0a0 \uc5f0\ud734 2",
"date": "2024-02-11"
},
{
"name": "3\u318d1\uc808",
"date": "2024-03-01"
},
{
"name": "\uc5b4\ub9b0\uc774\ub0a0",
"date": "2024-05-05"
},
{
"name": "\ubd80\ucc98\ub2d8 \uc624\uc2e0\ub0a0",
"date": "2024-05-15"
},
{
"name": "\ud604\ucda9\uc77c",
"date": "2024-06-06"
},
{
"name": "\uad11\ubcf5\uc808",
"date": "2024-08-15"
},
{
"name": "\ucd94\uc11d \uc5f0\ud734 1",
"date": "2024-09-16"
},
{
"name": "\ucd94\uc11d",
"date": "2024-09-17"
},
{
"name": "\ucd94\uc11d \uc5f0\ud734 2",
"date": "2024-09-18"
},
{
"name": "\uac1c\ucc9c\uc808",
"date": "2024-10-03"
},
{
"name": "\ud55c\uae00\ub0a0",
"date": "2024-10-09"
},
{
"name": "\ud06c\ub9ac\uc2a4\ub9c8\uc2a4",
"date": "2024-12-15"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@
"name": "V\u00fdro\u010die Slovensk\u00e9ho n\u00e1rodn\u00e9ho povstania",
"date": "2024-08-29"
},
{
"name": "De\u0148 \u00dastavy Slovenskej republiky",
"date": "2024-09-01"
},
{
"name": "Sedembolestn\u00e1 Panna M\u00e1ria",
"date": "2024-09-15"
Expand Down
Loading

0 comments on commit 643f10d

Please sign in to comment.