Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Uzbekistan Holidays #81

Merged
merged 5 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions lang/uzbekistan/en/holidays.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"Yangi yil": "New year",
"Xalqaro xotin-qizlar kuni": "International Women's Day",
"Navro'z": "Nowruz",
"Xotira va qadrlash kuni": "Remembrance Day",
"Mustaqillik kuni": "Independence Day",
"Ustoz va murabbiylar kuni": "Teachers Day",
"Konstitutsiya kuni": "Constitution Day",
"Ramazon Hayiti": "Eid al-Fitr",
"Qurbon Hayiti": "Eid al-Adha",
"Ramazon Hayiti 2": "Eid al-Fitr",
"Qurbon Hayiti 2": "Eid al-Adha"
}
13 changes: 13 additions & 0 deletions lang/uzbekistan/ru/holidays.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"Yangi yil": "Новый год",
"Xalqaro xotin-qizlar kuni": "Международный женский день",
"Navro'z": "Навруз",
"Xotira va qadrlash kuni": "День памяти и почестей",
"Mustaqillik kuni": "День Независимости",
"Ustoz va murabbiylar kuni": "День учителя",
"Konstitutsiya kuni": "День Конституции",
"Ramazon Hayiti": "Рамазан Хаит",
"Qurbon Hayiti": "Курбан Хаит",
"Ramazon Hayiti 2": "Рамазан Хаит",
"Qurbon Hayiti 2": "Курбан Хаит"
}
164 changes: 164 additions & 0 deletions src/Countries/Uzbekistan.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
<?php

namespace Spatie\Holidays\Countries;

use Carbon\CarbonImmutable;

class Uzbekistan extends Country
{
/**
* Islamic holidays (Ramadan & Sacrifice) are obtained constantly from 1991 to 2037 (https://www.timeanddate.com/holidays/uzbekistan/)
*/
protected const ramadanHolidays = [
1991 => '04-16',
1992 => '04-04',
1993 => '03-25',
1994 => '03-14',
1995 => '03-03',
1996 => '02-21',
1997 => '02-09',
1998 => '01-30',
1999 => '01-19',
2000 => [
'01-08',
'12-28',
],
2001 => '12-17',
2002 => '12-06',
2003 => '11-26',
2004 => '11-14',
2005 => '11-04',
2006 => '10-24',
2007 => '10-13',
2008 => '10-02',
2009 => '09-21',
2010 => '09-10',
2011 => '08-31',
2012 => '08-19',
2013 => '08-08',
2014 => '07-29',
2015 => '07-18',
2016 => '07-07',
2017 => '06-26',
2018 => '06-15',
2019 => '06-04',
2020 => '05-24',
2021 => '05-13',
2022 => '05-02',
2023 => '04-21',
2024 => '04-10',
2025 => '03-31',
2026 => '03-20',
2027 => '03-10',
2028 => '02-27',
2029 => '02-15',
2030 => '02-05',
2031 => '01-25',
2032 => '01-14',
2033 => [
'01-03',
'12-23',
],
2034 => '12-12',
2035 => '12-02',
2036 => '11-20',
2037 => '11-10',
];

public const sacrificeHolidays = [
1991 => '06-23',
1992 => '06-11',
1993 => '06-01',
1994 => '05-21',
1995 => '05-10',
1996 => '04-29',
1997 => '04-18',
1998 => '04-08',
1999 => '03-28',
2000 => '03-16',
2001 => '03-06',
2002 => '02-23',
2003 => '02-12',
2004 => '02-02',
2005 => '01-21',
2006 => [
'01-10',
'12-31',
],
2007 => '12-20',
2008 => '12-09',
2009 => '11-28',
2010 => '11-17',
2011 => '11-07',
2012 => '10-26',
2013 => '10-15',
2014 => '10-05',
2015 => '09-24',
2016 => '09-13',
2017 => '09-02',
2018 => '08-22',
2019 => '08-11',
2020 => '07-31',
2021 => '07-20',
2022 => '07-09',
2023 => '06-28',
2024 => '06-17',
2025 => '06-07',
2026 => '05-27',
2027 => '05-17',
2028 => '05-05',
2029 => '04-24',
2030 => '04-14',
2031 => '04-03',
2032 => '03-22',
2033 => '03-12',
2034 => '03-01',
2035 => '02-18',
2036 => '02-08',
2037 => '01-27',
];

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

protected function allHolidays(int $year): array
{
//After gaining independence on September 1, 1991, Uzbekistan introduced a new set of public holidays.
if ($year < 1991) {
return [];
}

return array_merge([
'Yangi yil' => '01-01',
'Xalqaro xotin-qizlar kuni' => '03-08',
'Navro\'z' => '03-21',
'Xotira va qadrlash kuni' => '05-09',
'Mustaqillik kuni' => '09-01',
'Ustoz va murabbiylar kuni' => '10-01',
'Konstitutsiya kuni' => '12-08',
], $this->variableHolidays($year));
}

/** @return array<string, CarbonImmutable> */
protected function variableHolidays(int $year): array
{
$holidays = [];

if (isset(self::ramadanHolidays[$year])) {
foreach ((array) self::ramadanHolidays[$year] as $key => $holiday) {
$prefix = $key == 0 ? '' : ' '.($key + 1);
$holidays['Ramazon Hayiti'.$prefix] = $holiday;
}
}
if (isset(self::sacrificeHolidays[$year])) {
foreach ((array) self::sacrificeHolidays[$year] as $key => $holiday) {
$prefix = $key == 0 ? '' : ' '.($key + 1);
$holidays['Qurbon Hayiti'.$prefix] = $holiday;
}
}

return $holidays;

Check failure on line 162 in src/Countries/Uzbekistan.php

View workflow job for this annotation

GitHub Actions / phpstan

Method Spatie\Holidays\Countries\Uzbekistan::variableHolidays() should return array<string, Carbon\CarbonImmutable> but returns array<string, string>.
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[
{
"name": "Yangi yil",
"date": "2024-01-01"
},
{
"name": "Xalqaro xotin-qizlar kuni",
"date": "2024-03-08"
},
{
"name": "Navro'z",
"date": "2024-03-21"
},
{
"name": "Xotira va qadrlash kuni",
"date": "2024-05-09"
},
{
"name": "Mustaqillik kuni",
"date": "2024-09-01"
},
{
"name": "Ustoz va murabbiylar kuni",
"date": "2024-10-01"
},
{
"name": "Konstitutsiya kuni",
"date": "2024-12-08"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[
{
"name": "New year",
"date": "2024-01-01"
},
{
"name": "International Women's Day",
"date": "2024-03-08"
},
{
"name": "Nowruz",
"date": "2024-03-21"
},
{
"name": "Eid al-Fitr",
"date": "2024-04-10"
},
{
"name": "Remembrance Day",
"date": "2024-05-09"
},
{
"name": "Eid al-Adha",
"date": "2024-06-17"
},
{
"name": "Independence Day",
"date": "2024-09-01"
},
{
"name": "Teachers Day",
"date": "2024-10-01"
},
{
"name": "Constitution Day",
"date": "2024-12-08"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[
{
"name": "\u041d\u043e\u0432\u044b\u0439 \u0433\u043e\u0434",
"date": "2024-01-01"
},
{
"name": "\u041c\u0435\u0436\u0434\u0443\u043d\u0430\u0440\u043e\u0434\u043d\u044b\u0439 \u0436\u0435\u043d\u0441\u043a\u0438\u0439 \u0434\u0435\u043d\u044c",
"date": "2024-03-08"
},
{
"name": "\u041d\u0430\u0432\u0440\u0443\u0437",
"date": "2024-03-21"
},
{
"name": "\u0420\u0430\u043c\u0430\u0437\u0430\u043d \u0425\u0430\u0438\u0442",
"date": "2024-04-10"
},
{
"name": "\u0414\u0435\u043d\u044c \u043f\u0430\u043c\u044f\u0442\u0438 \u0438 \u043f\u043e\u0447\u0435\u0441\u0442\u0435\u0439",
"date": "2024-05-09"
},
{
"name": "\u041a\u0443\u0440\u0431\u0430\u043d \u0425\u0430\u0438\u0442",
"date": "2024-06-17"
},
{
"name": "\u0414\u0435\u043d\u044c \u041d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438",
"date": "2024-09-01"
},
{
"name": "\u0414\u0435\u043d\u044c \u0443\u0447\u0438\u0442\u0435\u043b\u044f",
"date": "2024-10-01"
},
{
"name": "\u0414\u0435\u043d\u044c \u041a\u043e\u043d\u0441\u0442\u0438\u0442\u0443\u0446\u0438\u0438",
"date": "2024-12-08"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[
{
Nielsvanpach marked this conversation as resolved.
Show resolved Hide resolved
"name": "Yangi yil",
"date": "2000-01-01"
},
{
"name": "Ramazon Hayiti",
"date": "2000-01-08"
},
{
"name": "Xalqaro xotin-qizlar kuni",
"date": "2000-03-08"
},
{
"name": "Qurbon Hayiti",
"date": "2000-03-16"
},
{
"name": "Navro'z",
"date": "2000-03-21"
},
{
"name": "Xotira va qadrlash kuni",
"date": "2000-05-09"
},
{
"name": "Mustaqillik kuni",
"date": "2000-09-01"
},
{
"name": "Ustoz va murabbiylar kuni",
"date": "2000-10-01"
},
{
"name": "Konstitutsiya kuni",
"date": "2000-12-08"
},
{
"name": "Ramazon Hayiti 2",
"date": "2000-12-28"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[
{
"name": "Yangi yil",
"date": "2006-01-01"
},
{
"name": "Qurbon Hayiti",
"date": "2006-01-10"
},
{
"name": "Xalqaro xotin-qizlar kuni",
"date": "2006-03-08"
},
{
"name": "Navro'z",
"date": "2006-03-21"
},
{
"name": "Xotira va qadrlash kuni",
"date": "2006-05-09"
},
{
"name": "Mustaqillik kuni",
"date": "2006-09-01"
},
{
"name": "Ustoz va murabbiylar kuni",
"date": "2006-10-01"
},
{
"name": "Ramazon Hayiti",
"date": "2006-10-24"
},
{
"name": "Konstitutsiya kuni",
"date": "2006-12-08"
},
{
"name": "Qurbon Hayiti 2",
"date": "2006-12-31"
}
]
Loading
Loading