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

NYP: added Pakistani holidays and test case #99

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 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
52 changes: 52 additions & 0 deletions src/Countries/Pakistan.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

namespace Spatie\Holidays\Countries;

use Carbon\CarbonImmutable;

class Pakistan extends Country
{
/**
* Country Code
NabeelYousafPasha marked this conversation as resolved.
Show resolved Hide resolved
*
* @return string
NabeelYousafPasha marked this conversation as resolved.
Show resolved Hide resolved
*/
public function countryCode(): string
{
return 'pk';
}

/**
* All Holiday In Country
NabeelYousafPasha marked this conversation as resolved.
Show resolved Hide resolved
*
* @param integer $year
*
* @return array<string, CarbonImmutable|string>
*/
protected function allHolidays(int $year): array
{
return array_merge([
'Kashmir Solidarity Day' => '02-05',
'Pakistan Resolution Day' => '03-23',
'Labour Day' => '05-01',
'Independence Day' => '08-14',
'Defence Day' => '06-06',
'Iqbal Day' => '11-09',
'Quaid-e-Azam Day' => '12-25',
], $this->variableHolidays($year));
}

/**
*
* @return array<string, CarbonImmutable>
* */
protected function variableHolidays(int $year): array
{
// As Islamic holidays are lunar based.
// https://github.com/spatie/holidays/discussions/79

return [
//
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[
{
"name": "Kashmir Solidarity Day",
"date": "2024-02-05"
},
{
"name": "Pakistan Resolution Day",
"date": "2024-03-23"
},
{
"name": "Labour Day",
"date": "2024-05-01"
},
{
"name": "Defence Day",
"date": "2024-06-06"
},
{
"name": "Independence Day",
"date": "2024-08-14"
},
{
"name": "Iqbal Day",
"date": "2024-11-09"
},
{
"name": "Quaid-e-Azam Day",
"date": "2024-12-25"
}
]
18 changes: 18 additions & 0 deletions tests/Countries/PakistanTest.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 pakistani holidays', function () {
CarbonImmutable::setTestNowAndTimezone('2024-01-01');

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

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

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