Skip to content

Commit

Permalink
Adds UK bank holiday for Queen Elizabeth II’s funeral (#287)
Browse files Browse the repository at this point in the history
Adds bank holiday for Queen Elizabeth II’s funeral
  • Loading branch information
freshleafmedia authored Sep 19, 2022
1 parent 42dd9a5 commit 156f0dc
Show file tree
Hide file tree
Showing 3 changed files with 140 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ to [Semantic Versioning](https://semver.org).

- Added all examples as shown on the documentation site as a convenience to developers who like to have all
information in a single place.
- Added bank holiday for Queen Elizabeth II’s State Funeral on 19 September 2022 to United Kingdom

### Changed

Expand Down
28 changes: 28 additions & 0 deletions src/Yasumi/Provider/UnitedKingdom.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public function initialize(): void
// Add any other holidays
$this->calculatePlatinumJubileeBankHoliday();
$this->calculateMotheringSunday();
$this->calculateQueenElizabethFuneralBankHoliday();
}

public function getSources(): array
Expand Down Expand Up @@ -203,6 +204,33 @@ protected function calculatePlatinumJubileeBankHoliday(): void
));
}

/**
* Queen Elizabeth II’s funeral is an extra bank holiday added on 10 September 2022
* to mark the last day of the period of national mourning.
*
* @see https://www.timeanddate.com/holidays/uk/queen-elizabeth-funeral
* @see https://www.gov.uk/government/news/bank-holiday-announced-for-her-majesty-queen-elizabeth-iis-state-funeral-on-monday-19-september
*
* @throws InvalidDateException
* @throws \InvalidArgumentException
* @throws UnknownLocaleException
* @throws \Exception
*/
protected function calculateQueenElizabethFuneralBankHoliday(): void
{
if (2022 !== $this->year) {
return;
}

$this->addHoliday(new Holiday(
'queenElizabethFuneralBankHoliday',
['en' => 'Queen Elizabeth II’s State Funeral Bank Holiday'],
new DateTime("$this->year-9-19", DateTimeZoneFactory::getDateTimeZone($this->timezone)),
$this->locale,
Holiday::TYPE_BANK
));
}

/**
* Christmas Day is celebrated in the United Kingdom on December 25. It traditionally celebrates Jesus Christ's
* birth but many aspects of this holiday have pagan origins. Christmas is a time for many people to give and
Expand Down
111 changes: 111 additions & 0 deletions tests/UnitedKingdom/QueenElizabethFuneralBankHolidayTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<?php

declare(strict_types=1);
/*
* This file is part of the Yasumi package.
*
* Copyright (c) 2015 - 2022 AzuyaLabs
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @author Sacha Telgenhof <me at sachatelgenhof dot com>
*/

namespace Yasumi\tests\UnitedKingdom;

use DateTime;
use DateTimeZone;
use Exception;
use Yasumi\Holiday;
use Yasumi\tests\HolidayTestCase;

/**
* Class for testing the Queen Elizabeth's Funeral Bank Holiday in the United Kingdom.
*/
class QueenElizabethFuneralBankHolidayTest extends UnitedKingdomBaseTestCase implements HolidayTestCase
{
/**
* The name of the holiday.
*/
public const HOLIDAY = 'queenElizabethFuneralBankHoliday';

/**
* The year in which the holiday occurred.
*/
public const ACTIVE_YEAR = 2022;

/**
* The date on which the holiday occurred.
*/
public const ACTIVE_DATE = '2022-9-19';

/**
* Tests the holiday defined in this test.
*
* @throws Exception
*/
public function testHoliday(): void
{
$this->assertHoliday(
self::REGION,
self::HOLIDAY,
self::ACTIVE_YEAR,
new DateTime(self::ACTIVE_DATE, new DateTimeZone(self::TIMEZONE))
);
}

/**
* Tests the holiday defined in this test before the year in which it occurred.
*
* @throws Exception
*/
public function testHolidayBeforeActive(): void
{
$this->assertNotHoliday(
self::REGION,
self::HOLIDAY,
$this->generateRandomYear(1000, self::ACTIVE_YEAR - 1)
);
}

/**
* Tests the holiday defined in this test after the year in which it occurred.
*
* @throws Exception
*/
public function testHolidayAfterActive(): void
{
$this->assertNotHoliday(
self::REGION,
self::HOLIDAY,
$this->generateRandomYear(self::ACTIVE_YEAR + 1)
);
}

/**
* Tests the translated name of the holiday defined in this test.
*/
public function testTranslation(): void
{
$this->assertTranslatedHolidayName(
self::REGION,
self::HOLIDAY,
self::ACTIVE_YEAR,
[self::LOCALE => 'Queen Elizabeth II’s State Funeral Bank Holiday']
);
}

/**
* Tests type of the holiday defined in this test.
*/
public function testHolidayType(): void
{
$this->assertHolidayType(
self::REGION,
self::HOLIDAY,
self::ACTIVE_YEAR,
Holiday::TYPE_BANK
);
}
}

0 comments on commit 156f0dc

Please sign in to comment.