From 26d8d72f644b2cc35e0f7c61ccc541909962f2a1 Mon Sep 17 00:00:00 2001 From: Christian Schmidt Date: Sun, 18 Aug 2019 11:19:18 +0200 Subject: [PATCH 1/2] Add one-off exceptions for UK bank holidays --- CHANGELOG.md | 1 + src/Yasumi/Provider/UnitedKingdom.php | 27 +++++++++++++++++++ tests/UnitedKingdom/MayDayBankHolidayTest.php | 21 +++++++++++++++ tests/UnitedKingdom/SpringBankHolidayTest.php | 21 +++++++++++++++ 4 files changed, 70 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c7a85c99a..b9918e81e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/Yasumi/Provider/UnitedKingdom.php b/src/Yasumi/Provider/UnitedKingdom.php index e314ecb89..3c5eabe52 100644 --- a/src/Yasumi/Provider/UnitedKingdom.php +++ b/src/Yasumi/Provider/UnitedKingdom.php @@ -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'], @@ -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'], diff --git a/tests/UnitedKingdom/MayDayBankHolidayTest.php b/tests/UnitedKingdom/MayDayBankHolidayTest.php index 757f1e713..01e58bee7 100644 --- a/tests/UnitedKingdom/MayDayBankHolidayTest.php +++ b/tests/UnitedKingdom/MayDayBankHolidayTest.php @@ -48,6 +48,27 @@ public function testHoliday() ); } + /** + * Tests the holiday exception in 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 diff --git a/tests/UnitedKingdom/SpringBankHolidayTest.php b/tests/UnitedKingdom/SpringBankHolidayTest.php index 79c390e20..3c4db82e1 100644 --- a/tests/UnitedKingdom/SpringBankHolidayTest.php +++ b/tests/UnitedKingdom/SpringBankHolidayTest.php @@ -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 From d22c268b12558e1734841353cdc322eece3af865 Mon Sep 17 00:00:00 2001 From: Christian Schmidt Date: Sun, 18 Aug 2019 11:47:39 +0200 Subject: [PATCH 2/2] Fix comment --- tests/UnitedKingdom/MayDayBankHolidayTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/UnitedKingdom/MayDayBankHolidayTest.php b/tests/UnitedKingdom/MayDayBankHolidayTest.php index 01e58bee7..24578db20 100644 --- a/tests/UnitedKingdom/MayDayBankHolidayTest.php +++ b/tests/UnitedKingdom/MayDayBankHolidayTest.php @@ -49,7 +49,7 @@ public function testHoliday() } /** - * Tests the holiday exception in 2020. + * Tests the holiday exception in 1995 and 2020. * @throws \ReflectionException */ public function testHolidayExceptions()