Skip to content

Commit

Permalink
Added Bahrain holidays
Browse files Browse the repository at this point in the history
  • Loading branch information
bo3bdo committed Jan 18, 2024
1 parent d8cbb76 commit c230c89
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 0 deletions.
43 changes: 43 additions & 0 deletions src/Countries/Bahrain.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

namespace Spatie\Holidays\Countries;

use Carbon\CarbonImmutable;

class Bahrain extends Country
{
public function countryCode(): string
{
return 'bh';
}

protected function allHolidays(int $year): array
{
throw new \Exception('Not implemented yet.');

return array_merge([

Check failure on line 18 in src/Countries/Bahrain.php

View workflow job for this annotation

GitHub Actions / phpstan

Unreachable statement - code above always terminates.
'New Year Day' => '01-01',
'Eid al Fitr Holiday 1' => '04-10',
'Eid al Fitr Holiday 2' => '04-11',
'Eid al Fitr Holiday 3' => '04-12',
'Labour Day' => '05-01',
'Eid al Adha Holiday 1' => '06-16',
'Eid al Adha Holiday 2' => '06-17',
'Eid al Adha Holiday 3' => '06-18',
'Islamic New Year' => '07-07',
'Ashura Holiday 1' => '07-16',
'Ashura Holiday 2' => '07-17',
'Prophet Muhammads Birthday' => '07-15',
'National Day' => '12-16',
'National Day Holiday' => '12-17',
], $this->variableHolidays($year));
}

/** @return array<string, CarbonImmutable> */
protected function variableHolidays(int $year): array
{
$easter = CarbonImmutable::createFromTimestamp(easter_date($year))->setTimezone('Asia/Bahrain');

return [];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
[
{
"name": "New Year Day",
"date": "2024-01-01"
},
{
"name": "Eid al Fitr Holiday 1",
"date": "2024-04-10"
},
{
"name": "Eid al Fitr Holiday 2",
"date": "2024-04-11"
},
{
"name": "Eid al Fitr Holiday 3",
"date": "2024-04-12"
},
{
"name": "Labour Day",
"date": "2024-05-01"
},
{
"name": "Eid al Adha Holiday 1",
"date": "2024-06-16"
},
{
"name": "Eid al Adha Holiday 2",
"date": "2024-06-17"
},
{
"name": "Eid al Adha Holiday 3",
"date": "2024-06-18"
},
{
"name": "Islamic New Year",
"date": "2024-07-07"
},
{
"name": "Ashura Holiday 1",
"date": "2024-07-16"
},
{
"name": "Ashura Holiday 2",
"date": "2024-07-17"
},
{
"name": "Prophet Muhammads Birthday",
"date": "2024-07-15"
},
{
"name": "National Day",
"date": "2024-12-16"
},
{
"name": "National Day Holiday",
"date": "2024-12-17"
}
]
18 changes: 18 additions & 0 deletions tests/Countries/BahrainTest.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 bahrain holidays', function () {
CarbonImmutable::setTestNowAndTimezone('2024-01-01');

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

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

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

0 comments on commit c230c89

Please sign in to comment.