Skip to content

Commit 08f3260

Browse files
committed
feat(canada): Nunavut Day for the Nunavut province
Signed-off-by: Sacha Telgenhof <me@sachatelgenhof.com>
1 parent 37628ea commit 08f3260

3 files changed

Lines changed: 108 additions & 1 deletion

File tree

src/Yasumi/Provider/Canada/Nunavut.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
namespace Yasumi\Provider\Canada;
1919

2020
use Yasumi\Exception\UnknownLocaleException;
21+
use Yasumi\Holiday;
2122
use Yasumi\Provider\Canada;
23+
use Yasumi\Provider\DateTimeZoneFactory;
2224

2325
/**
2426
* Provider for all holidays in Nunavut (Canada).
@@ -50,5 +52,32 @@ public function initialize(): void
5052

5153
$this->calculateCivicHoliday();
5254
$this->calculateVictoriaDay();
55+
$this->calculateNunavutDay();
56+
}
57+
58+
/**
59+
* Nunavut Day – July 9, originated as a paid holiday for Nunavut Tunngavik Incorporated
60+
* and regional Inuit associations. It became a half-day holiday for government employees
61+
* in 1999 and a full day in 2001.
62+
*
63+
* @see https://en.wikipedia.org/wiki/Nunavut_Day
64+
*
65+
* @throws \InvalidArgumentException
66+
* @throws UnknownLocaleException
67+
* @throws \Exception
68+
*/
69+
protected function calculateNunavutDay(): void
70+
{
71+
if ($this->year < 1999) {
72+
return;
73+
}
74+
75+
$this->addHoliday(new Holiday(
76+
'nunavutDay',
77+
['en' => 'Nunavut Day'],
78+
new \DateTime("{$this->year}-07-09", DateTimeZoneFactory::getDateTimeZone($this->timezone)),
79+
$this->locale,
80+
Holiday::TYPE_OBSERVANCE
81+
));
5382
}
5483
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<?php
2+
3+
declare(strict_types = 1);
4+
5+
/**
6+
* This file is part of the 'Yasumi' package.
7+
*
8+
* The easy PHP Library for calculating holidays.
9+
*
10+
* Copyright (c) 2015 - 2025 AzuyaLabs
11+
*
12+
* For the full copyright and license information, please view the LICENSE
13+
* file that was distributed with this source code.
14+
*
15+
* @author Sacha Telgenhof <me at sachatelgenhof dot com>
16+
*/
17+
18+
namespace Yasumi\tests\Canada\Nunavut;
19+
20+
use Yasumi\Holiday;
21+
use Yasumi\tests\HolidayTestCase;
22+
23+
/*
24+
* Nunavut Day – July 9, originated as a paid holiday for Nunavut Tunngavik Incorporated
25+
* and regional Inuit associations. It became a half-day holiday for government employees
26+
* in 1999 and a full day in 2001.
27+
*/
28+
class NunavutDayTest extends NunavutBaseTestCase implements HolidayTestCase
29+
{
30+
public const HOLIDAY = 'nunavutDay';
31+
32+
public const ESTABLISHMENT_YEAR = 1999;
33+
34+
public function testNunavutDayOnAfterEstablishment(): void
35+
{
36+
$year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR);
37+
$this->assertHoliday(
38+
self::REGION,
39+
self::HOLIDAY,
40+
$year,
41+
new \DateTime("{$year}-07-09", new \DateTimeZone(self::TIMEZONE))
42+
);
43+
}
44+
45+
public function testLabourDayBeforeEstablishment(): void
46+
{
47+
$this->assertNotHoliday(
48+
self::REGION,
49+
self::HOLIDAY,
50+
$this->generateRandomYear(1000, self::ESTABLISHMENT_YEAR - 1)
51+
);
52+
}
53+
54+
public function testTranslation(): void
55+
{
56+
$this->assertTranslatedHolidayName(
57+
self::REGION,
58+
self::HOLIDAY,
59+
$this->generateRandomYear(self::ESTABLISHMENT_YEAR),
60+
[self::LOCALE => 'Nunavut Day']
61+
);
62+
}
63+
64+
public function testHolidayType(): void
65+
{
66+
$this->assertHolidayType(
67+
self::REGION,
68+
self::HOLIDAY,
69+
$this->generateRandomYear(self::ESTABLISHMENT_YEAR),
70+
Holiday::TYPE_OBSERVANCE
71+
);
72+
}
73+
}

tests/Canada/Nunavut/NunavutTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,12 @@ public function testOfficialHolidays(): void
5858
*/
5959
public function testObservedHolidays(): void
6060
{
61-
$this->assertDefinedHolidays([], self::REGION, $this->year, Holiday::TYPE_OBSERVANCE);
61+
$holidays = [];
62+
63+
if ($this->year >= 1999) {
64+
$holidays[] = 'nunavutDay';
65+
}
66+
$this->assertDefinedHolidays($holidays, self::REGION, $this->year, Holiday::TYPE_OBSERVANCE);
6267
}
6368

6469
/**

0 commit comments

Comments
 (0)