From 5411dc7b68405cb70347125326b50e21fc21113a Mon Sep 17 00:00:00 2001 From: shoxrux1996 Date: Thu, 18 Jan 2024 18:27:03 +0500 Subject: [PATCH] Add Uzbekistan Holidays --- src/Countries/Uzbekistan.php | 38 +++++++++++++++++++ .../it_can_calculate_uzbekistan_holidays.snap | 30 +++++++++++++++ tests/Countries/UzbekistanTest.php | 18 +++++++++ 3 files changed, 86 insertions(+) create mode 100644 src/Countries/Uzbekistan.php create mode 100644 tests/.pest/snapshots/Countries/UzbekistanTest/it_can_calculate_uzbekistan_holidays.snap create mode 100644 tests/Countries/UzbekistanTest.php diff --git a/src/Countries/Uzbekistan.php b/src/Countries/Uzbekistan.php new file mode 100644 index 000000000..76859c163 --- /dev/null +++ b/src/Countries/Uzbekistan.php @@ -0,0 +1,38 @@ + */ + protected function allHolidays(int $year): array + { + 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 */ + protected function variableHolidays(int $year): array + { + $easter = CarbonImmutable::createFromTimestamp(easter_date($year)) + ->setTimezone('Asia/Tashkent'); + + return [ + //'Ramazon Hayiti' (Eid al-Fitr) and 'Qurbon Hayiti' (Eid al-Adha) will be added after the implementation of Islamic holidays + ]; + } +} diff --git a/tests/.pest/snapshots/Countries/UzbekistanTest/it_can_calculate_uzbekistan_holidays.snap b/tests/.pest/snapshots/Countries/UzbekistanTest/it_can_calculate_uzbekistan_holidays.snap new file mode 100644 index 000000000..045629443 --- /dev/null +++ b/tests/.pest/snapshots/Countries/UzbekistanTest/it_can_calculate_uzbekistan_holidays.snap @@ -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" + } +] \ No newline at end of file diff --git a/tests/Countries/UzbekistanTest.php b/tests/Countries/UzbekistanTest.php new file mode 100644 index 000000000..94be8a699 --- /dev/null +++ b/tests/Countries/UzbekistanTest.php @@ -0,0 +1,18 @@ +get(); + + expect($holidays) + ->toBeArray() + ->not()->toBeEmpty(); + + expect(formatDates($holidays))->toMatchSnapshot(); +});