Skip to content

Commit

Permalink
Add Bangladesh holidays (#21)
Browse files Browse the repository at this point in the history
Co-authored-by: Ariful Alam <[email protected]>
  • Loading branch information
arifszn and Ariful Alam authored Jan 19, 2024
1 parent 5941d7b commit 46fc7f3
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/Countries/Bangladesh.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace Spatie\Holidays\Countries;

use Carbon\CarbonImmutable;

class Bangladesh extends Country
{
public function countryCode(): string
{
return 'bd';
}

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

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

View workflow job for this annotation

GitHub Actions / phpstan

Method Spatie\Holidays\Countries\Bangladesh::allHolidays() should return array<string, Carbon\CarbonImmutable> but returns array<string, Carbon\CarbonImmutable|string>.
'International Mother Language Day' => '02-21',
'Birthday of Sheikh Mujibur Rahman' => '03-17',
'Independence Day' => '03-26',
'Bengali New Year' => '04-14',
'May Day' => '05-01',
'National Mourning Day' => '08-15',
'Victory Day' => '12-16',
'Christmas Day' => '12-25',
], $this->variableHolidays($year));
}

/** @return array<string, CarbonImmutable> */
protected function variableHolidays(int $year): array
{
// The variable holidays all follow the lunar calendar, so their dates are not confirmed.
return [];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[
{
"name": "International Mother Language Day",
"date": "2024-02-21"
},
{
"name": "Birthday of Sheikh Mujibur Rahman",
"date": "2024-03-17"
},
{
"name": "Independence Day",
"date": "2024-03-26"
},
{
"name": "Bengali New Year",
"date": "2024-04-14"
},
{
"name": "May Day",
"date": "2024-05-01"
},
{
"name": "National Mourning Day",
"date": "2024-08-15"
},
{
"name": "Victory Day",
"date": "2024-12-16"
},
{
"name": "Christmas Day",
"date": "2024-12-25"
}
]
18 changes: 18 additions & 0 deletions tests/Countries/BangladeshTest.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 bangladesh holidays', function () {
CarbonImmutable::setTestNowAndTimezone('2024-01-01');

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

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

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

0 comments on commit 46fc7f3

Please sign in to comment.