Skip to content

Commit

Permalink
Add Uzbekistan Holidays
Browse files Browse the repository at this point in the history
  • Loading branch information
shoxrux1996 committed Jan 18, 2024
1 parent 82267a8 commit 5411dc7
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/Countries/Uzbekistan.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace Spatie\Holidays\Countries;

use Carbon\CarbonImmutable;

class Uzbekistan extends Country
{
public function countryCode(): string
{
return 'uz';
}

/** @return array<string, CarbonImmutable> */
protected function allHolidays(int $year): array
{
return array_merge([

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

View workflow job for this annotation

GitHub Actions / phpstan

Method Spatie\Holidays\Countries\Uzbekistan::allHolidays() should return array<string, Carbon\CarbonImmutable> but returns array<string, Carbon\CarbonImmutable|string>.
'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
{
$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
];
}
}
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"
}
]
18 changes: 18 additions & 0 deletions tests/Countries/UzbekistanTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Spatie\Holidays\Tests\Countries;

use Carbon\CarbonImmutable;
use Spatie\Holidays\Holidays;

it('can calculate uzbekistan holidays', function () {
CarbonImmutable::setTestNowAndTimezone('2024-01-01');

$holidays = Holidays::for(country: 'uz')->get();

expect($holidays)
->toBeArray()
->not()->toBeEmpty();

expect(formatDates($holidays))->toMatchSnapshot();
});

0 comments on commit 5411dc7

Please sign in to comment.