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

Add exceptions for UK bank holidays #160

Merged
merged 2 commits into from
Aug 18, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
- Updated the translation for the Assumption of Mary holiday for the 'fr_FR' locale [\#155](https://github.com/azuyalabs/yasumi/pull/155) ([pioc92](https://github.com/pioc92))

### Fixed
- Fixed one-off exceptions for May Day Bank Holiday in 1995 and 2020 and Spring Bank Holiday in 2002 and 2012 (United Kingdom) [\#160](https://github.com/azuyalabs/yasumi/pull/160) ([c960657](https://github.com/c960657))

### Removed

Expand Down
27 changes: 27 additions & 0 deletions src/Yasumi/Provider/UnitedKingdom.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,19 @@ private function calculateMayDayBankHoliday(): void
return;
}

// Moved to 8 May to commemorate the 50th (1995) and 75th (2020) anniversary of VE Day.
if ($this->year == 1995 || $this->year == 2020) {
$this->addHoliday(new Holiday(
'mayDayBankHoliday',
['en_GB' => 'May Day Bank Holiday'],
new DateTime("$this->year-5-8", new DateTimeZone($this->timezone)),
$this->locale,
Holiday::TYPE_BANK
));

return;
}

$this->addHoliday(new Holiday(
'mayDayBankHoliday',
['en_GB' => 'May Day Bank Holiday'],
Expand Down Expand Up @@ -150,6 +163,20 @@ private function calculateSpringBankHoliday(): void
return;
}

// Moved to 4 June for the celebration of the Golden (2002) and Diamond (2012) Jubilee
// of Elizabeth II.
if ($this->year == 2002 || $this->year == 2012) {
$this->addHoliday(new Holiday(
'springBankHoliday',
['en_GB' => 'Spring Bank Holiday'],
new DateTime("$this->year-6-4", new DateTimeZone($this->timezone)),
$this->locale,
Holiday::TYPE_BANK
));

return;
}

$this->addHoliday(new Holiday(
'springBankHoliday',
['en_GB' => 'Spring Bank Holiday'],
Expand Down
21 changes: 21 additions & 0 deletions tests/UnitedKingdom/MayDayBankHolidayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,27 @@ public function testHoliday()
);
}

/**
* Tests the holiday exception in 1995 and 2020.
* @throws \ReflectionException
*/
public function testHolidayExceptions()
{
$this->assertHoliday(
self::REGION,
self::HOLIDAY,
1995,
new DateTime("1995-5-8", new DateTimeZone(self::TIMEZONE))
);

$this->assertHoliday(
self::REGION,
self::HOLIDAY,
2020,
new DateTime("2020-5-8", new DateTimeZone(self::TIMEZONE))
);
}

/**
* Tests the holiday defined in this test before establishment.
* @throws \ReflectionException
Expand Down
21 changes: 21 additions & 0 deletions tests/UnitedKingdom/SpringBankHolidayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,27 @@ public function testHoliday()
);
}

/**
* Tests the holiday exceptions in 2002 and 2012.
* @throws \ReflectionException
*/
public function testHolidayException()
{
$this->assertHoliday(
self::REGION,
self::HOLIDAY,
2002,
new DateTime("2002-6-4", new DateTimeZone(self::TIMEZONE))
);

$this->assertHoliday(
self::REGION,
self::HOLIDAY,
2012,
new DateTime("2012-6-4", new DateTimeZone(self::TIMEZONE))
);
}

/**
* Tests the holiday defined in this test before establishment.
* @throws \ReflectionException
Expand Down