From ae895d0fb9cbfb5ff642a1bebf3be3708cd2e38a Mon Sep 17 00:00:00 2001 From: Sacha Telgenhof Date: Sun, 15 Oct 2023 13:16:05 +0000 Subject: [PATCH] Remove summer and wintertime (#322) Summertime and Wintertime in the Netherlands and Denmark as these can't be reliably established for historical dates and aren't true holidays in the context of Yasumi. Refer to this discussion for further details and rationale. Signed-off-by: Sacha Telgenhof --- CHANGELOG.md | 4 + src/Yasumi/Provider/Denmark.php | 10 -- src/Yasumi/Provider/Netherlands.php | 36 ------ tests/Base/HolidayBetweenFilterTest.php | 18 +-- tests/Base/HolidayFiltersTest.php | 8 +- tests/Base/HolidayOnFilterTest.php | 6 - tests/Denmark/DenmarkTest.php | 11 -- tests/Denmark/SummerTimeTest.php | 127 ------------------- tests/Denmark/WinterTimeTest.php | 125 ------------------- tests/Netherlands/NetherlandsTest.php | 11 -- tests/Netherlands/SummerTimeTest.php | 155 ------------------------ tests/Netherlands/WinterTimeTest.php | 130 -------------------- 12 files changed, 12 insertions(+), 629 deletions(-) delete mode 100644 tests/Denmark/SummerTimeTest.php delete mode 100644 tests/Denmark/WinterTimeTest.php delete mode 100644 tests/Netherlands/SummerTimeTest.php delete mode 100644 tests/Netherlands/WinterTimeTest.php diff --git a/CHANGELOG.md b/CHANGELOG.md index ceafc3eb9..10224da74 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,10 @@ changes. ### Removed +- Summertime and Wintertime in the Netherlands and Denmark as these can't be reliably established for historical dates and + aren't true holidays in the context of Yasumi. Refer to this [discussion](https://github.com/azuyalabs/yasumi/discussions/321) + for further details and rationale. + ## [2.6.0] - 2023-04-27 ### Added diff --git a/src/Yasumi/Provider/Denmark.php b/src/Yasumi/Provider/Denmark.php index 82133fb13..4afff9161 100644 --- a/src/Yasumi/Provider/Denmark.php +++ b/src/Yasumi/Provider/Denmark.php @@ -63,16 +63,6 @@ public function initialize(): void $this->addHoliday($this->christmasEve($this->year, $this->timezone, $this->locale)); $this->addHoliday($this->newYearsEve($this->year, $this->timezone, $this->locale, Holiday::TYPE_OBSERVANCE)); $this->calculateConstitutionDay(); - - $summerTime = $this->summerTime($this->year, $this->timezone, $this->locale); - if ($summerTime instanceof Holiday) { - $this->addHoliday($summerTime); - } - - $winterTime = $this->winterTime($this->year, $this->timezone, $this->locale); - if ($winterTime instanceof Holiday) { - $this->addHoliday($winterTime); - } } public function getSources(): array diff --git a/src/Yasumi/Provider/Netherlands.php b/src/Yasumi/Provider/Netherlands.php index e2ff63bb5..5b5fe67ce 100644 --- a/src/Yasumi/Provider/Netherlands.php +++ b/src/Yasumi/Provider/Netherlands.php @@ -75,8 +75,6 @@ public function initialize(): void // Calculate other holidays $this->calculateCarnival(); - $this->calculateWinterTime(); - $this->calculateSummerTime(); $this->calculateStNicholasDay(); $this->calculateHalloween(); $this->calculatePrincesDay(); @@ -129,40 +127,6 @@ private function calculateCarnival(): void } } - /** - * Winter Time. - * - * The beginning of winter time. Winter time is also known as standard time. - * - * @throws \Exception - * - * @see \Yasumi\Provider\CommonHolidays::winterTime() - */ - private function calculateWinterTime(): void - { - $winterTime = $this->winterTime($this->year, $this->timezone, $this->locale); - if ($winterTime instanceof Holiday) { - $this->addHoliday($winterTime); - } - } - - /** - * Summer Time. - * - * The beginning of summer time. Summer time is also known as day lights saving time. - * - * @throws \Exception - * - * @see \Yasumi\Provider\CommonHolidays::summerTime() - */ - private function calculateSummerTime(): void - { - $summerTime = $this->summerTime($this->year, $this->timezone, $this->locale); - if ($summerTime instanceof Holiday) { - $this->addHoliday($summerTime); - } - } - /** * St. Nicholas' Day. * diff --git a/tests/Base/HolidayBetweenFilterTest.php b/tests/Base/HolidayBetweenFilterTest.php index 8cb860d81..a16996640 100644 --- a/tests/Base/HolidayBetweenFilterTest.php +++ b/tests/Base/HolidayBetweenFilterTest.php @@ -37,7 +37,6 @@ public function testHolidaysBetweenDateRange(): void self::assertArrayHasKey('goodFriday', $betweenHolidays); self::assertArrayHasKey('easter', $betweenHolidays); - self::assertArrayHasKey('summerTime', $betweenHolidays); self::assertArrayHasKey('easterMonday', $betweenHolidays); self::assertArrayHasKey('kingsDay', $betweenHolidays); self::assertArrayHasKey('internationalWorkersDay', $betweenHolidays); @@ -58,17 +57,16 @@ public function testHolidaysBetweenDateRange(): void self::assertArrayNotHasKey('valentinesDay', $betweenHolidays); self::assertArrayNotHasKey('princesDay', $betweenHolidays); self::assertArrayNotHasKey('worldAnimalDay', $betweenHolidays); - self::assertArrayNotHasKey('winterTime', $betweenHolidays); self::assertArrayNotHasKey('halloween', $betweenHolidays); self::assertArrayNotHasKey('stMartinsDay', $betweenHolidays); self::assertArrayNotHasKey('stNicholasDay', $betweenHolidays); self::assertArrayNotHasKey('christmasDay', $betweenHolidays); self::assertArrayNotHasKey('secondChristmasDay', $betweenHolidays); - self::assertCount(13, $between); + self::assertCount(12, $between); self::assertNotCount(\count($holidays), $between); - self::assertEquals(13, $between->count()); + self::assertEquals(12, $between->count()); self::assertNotEquals(\count($holidays), $between->count()); } @@ -87,7 +85,6 @@ public function testHolidaysBetweenDateRangeWithDateTimeImmutable(): void self::assertArrayHasKey('goodFriday', $betweenHolidays); self::assertArrayHasKey('easter', $betweenHolidays); - self::assertArrayHasKey('summerTime', $betweenHolidays); self::assertArrayHasKey('easterMonday', $betweenHolidays); self::assertArrayHasKey('kingsDay', $betweenHolidays); self::assertArrayHasKey('internationalWorkersDay', $betweenHolidays); @@ -108,17 +105,16 @@ public function testHolidaysBetweenDateRangeWithDateTimeImmutable(): void self::assertArrayNotHasKey('valentinesDay', $betweenHolidays); self::assertArrayNotHasKey('princesDay', $betweenHolidays); self::assertArrayNotHasKey('worldAnimalDay', $betweenHolidays); - self::assertArrayNotHasKey('winterTime', $betweenHolidays); self::assertArrayNotHasKey('halloween', $betweenHolidays); self::assertArrayNotHasKey('stMartinsDay', $betweenHolidays); self::assertArrayNotHasKey('stNicholasDay', $betweenHolidays); self::assertArrayNotHasKey('christmasDay', $betweenHolidays); self::assertArrayNotHasKey('secondChristmasDay', $betweenHolidays); - self::assertCount(13, $between); + self::assertCount(12, $between); self::assertNotCount(\count($holidays), $between); - self::assertEquals(13, $between->count()); + self::assertEquals(12, $between->count()); self::assertNotEquals(\count($holidays), $between->count()); } @@ -166,7 +162,6 @@ public function testHolidaysBetweenDateRangeExclusiveStartEndDate(): void self::assertArrayHasKey('valentinesDay', $betweenHolidays); self::assertArrayHasKey('goodFriday', $betweenHolidays); self::assertArrayHasKey('easter', $betweenHolidays); - self::assertArrayHasKey('summerTime', $betweenHolidays); self::assertArrayHasKey('easterMonday', $betweenHolidays); self::assertArrayHasKey('kingsDay', $betweenHolidays); self::assertArrayHasKey('internationalWorkersDay', $betweenHolidays); @@ -181,17 +176,16 @@ public function testHolidaysBetweenDateRangeExclusiveStartEndDate(): void self::assertArrayNotHasKey('newYearsDay', $betweenHolidays); self::assertArrayNotHasKey('princesDay', $betweenHolidays); self::assertArrayNotHasKey('worldAnimalDay', $betweenHolidays); - self::assertArrayNotHasKey('winterTime', $betweenHolidays); self::assertArrayNotHasKey('halloween', $betweenHolidays); self::assertArrayNotHasKey('stMartinsDay', $betweenHolidays); self::assertArrayNotHasKey('stNicholasDay', $betweenHolidays); self::assertArrayNotHasKey('christmasDay', $betweenHolidays); self::assertArrayNotHasKey('secondChristmasDay', $betweenHolidays); - self::assertCount(19, $between); + self::assertCount(18, $between); self::assertNotCount(\count($holidays), $between); - self::assertEquals(19, $between->count()); + self::assertEquals(18, $between->count()); self::assertNotEquals(\count($holidays), $between->count()); } diff --git a/tests/Base/HolidayFiltersTest.php b/tests/Base/HolidayFiltersTest.php index 5aca68812..d7cc3fd73 100644 --- a/tests/Base/HolidayFiltersTest.php +++ b/tests/Base/HolidayFiltersTest.php @@ -125,8 +125,6 @@ public function testSeasonalHolidaysFilter(): void $filteredHolidaysArray = iterator_to_array($filteredHolidays); // Assert array definitions - self::assertArrayHasKey('summerTime', $filteredHolidaysArray); - self::assertArrayHasKey('winterTime', $filteredHolidaysArray); self::assertArrayNotHasKey('newYearsDay', $filteredHolidaysArray); self::assertArrayNotHasKey('easter', $filteredHolidaysArray); self::assertArrayNotHasKey('easterMonday', $filteredHolidaysArray); @@ -155,9 +153,9 @@ public function testSeasonalHolidaysFilter(): void self::assertArrayNotHasKey('princesDay', $filteredHolidaysArray); // Assert number of results returned - self::assertCount(2, $filteredHolidays); + self::assertCount(0, $filteredHolidays); self::assertNotCount(\count($holidays), $filteredHolidays); - self::assertEquals(2, $filteredHolidays->count()); + self::assertEquals(0, $filteredHolidays->count()); self::assertNotEquals(\count($holidays), $filteredHolidays->count()); } @@ -176,8 +174,6 @@ public function testOtherHolidaysFilter(): void self::assertArrayHasKey('mothersDay', $filteredHolidaysArray); self::assertArrayHasKey('epiphany', $filteredHolidaysArray); self::assertArrayHasKey('princesDay', $filteredHolidaysArray); - self::assertArrayNotHasKey('summerTime', $filteredHolidaysArray); - self::assertArrayNotHasKey('winterTime', $filteredHolidaysArray); self::assertArrayNotHasKey('newYearsDay', $filteredHolidaysArray); self::assertArrayNotHasKey('easter', $filteredHolidaysArray); self::assertArrayNotHasKey('easterMonday', $filteredHolidaysArray); diff --git a/tests/Base/HolidayOnFilterTest.php b/tests/Base/HolidayOnFilterTest.php index 301e61270..83b3fdea7 100644 --- a/tests/Base/HolidayOnFilterTest.php +++ b/tests/Base/HolidayOnFilterTest.php @@ -31,7 +31,6 @@ public function testHolidaysOnDate(): void $holidayDates = [ 'goodFriday' => new \DateTime('03/25/2016', new \DateTimeZone($timezone)), 'easter' => new \DateTime('03/27/2016', new \DateTimeZone($timezone)), - 'summerTime' => new \DateTime('03/27/2016', new \DateTimeZone($timezone)), ]; foreach ($holidayDates as $name => $date) { @@ -52,7 +51,6 @@ public function testHolidaysNotOnDate(): void $holidayWrongDates = [ 'goodFriday' => new \DateTime('04/25/2016', new \DateTimeZone($timezone)), 'easter' => new \DateTime('03/22/2016', new \DateTimeZone($timezone)), - 'summerTime' => new \DateTime('12/27/2016', new \DateTimeZone($timezone)), ]; foreach ($holidayWrongDates as $name => $date) { @@ -77,9 +75,5 @@ public function testCorrectNumberOfHolidaysOnDate(): void // One holiday $holidaysOnDate = $holidays->on(new \DateTime('12/25/2016', new \DateTimeZone($timezone))); self::assertEquals(1, $holidaysOnDate->count()); - - // Multiple holidays - $holidaysOnDate = $holidays->on(new \DateTime('03/27/2016', new \DateTimeZone($timezone))); - self::assertGreaterThan(1, $holidaysOnDate->count()); } } diff --git a/tests/Denmark/DenmarkTest.php b/tests/Denmark/DenmarkTest.php index 8f013dc59..2e6ee7d3d 100644 --- a/tests/Denmark/DenmarkTest.php +++ b/tests/Denmark/DenmarkTest.php @@ -69,17 +69,6 @@ public function testObservedHolidays(): void ], self::REGION, $this->year, Holiday::TYPE_OBSERVANCE); } - /** - * Tests if all seasonal holidays in Denmark are defined by the provider class. - * - * @throws \Exception - */ - public function testSeasonalHolidays(): void - { - $year = $this->generateRandomYear(1980, 2037); - $this->assertDefinedHolidays(['summerTime', 'winterTime'], self::REGION, $year, Holiday::TYPE_SEASON); - } - /** * Tests if all bank holidays in Denmark are defined by the provider class. */ diff --git a/tests/Denmark/SummerTimeTest.php b/tests/Denmark/SummerTimeTest.php deleted file mode 100644 index 41c50bb8d..000000000 --- a/tests/Denmark/SummerTimeTest.php +++ /dev/null @@ -1,127 +0,0 @@ - - */ - -namespace Yasumi\tests\Denmark; - -use Yasumi\Holiday; - -/** - * Class for testing summer time in Denmark. - * - * @see: https://en.wikipedia.org/wiki/Time_in_the_Danish_Realm#History - */ -final class SummerTimeTest extends DaylightSavingTime -{ - /** The name of the holiday */ - public const HOLIDAY = 'summerTime'; - - /* List of transition dates that deviate from the known/defined rules. - * PHP derives the transition dates from the tz database which appear to - * be different for some dates */ - private array $deviantTransitions = [ - 1916 => '1916-05-14', - 1940 => '1940-05-14', - 1943 => '1943-03-29', - 1944 => '1944-04-03', - 1945 => '1945-04-02', - 1946 => '1946-05-01', - 1947 => '1947-05-04', - 1948 => '1948-05-09', - ]; - - public function __construct() - { - parent::__construct(); - - // no summertime defined in 1942 - if (false !== ($key = array_search(1942, $this->observedYears, true))) { - unset($this->observedYears[(int) $key]); - } - - // In version 2022f of the tz db, a correction for some years weere made for the summertime - // transitions. See: https://github.com/eggert/tz/blob/2022f/europe - if (1 === strcmp(\intltz_get_tz_data_version(), '2022f')) { - $this->swapObservation([1917, 1918, 1949]); - - $this->deviantTransitions[1916] = '1916-04-30'; - $this->deviantTransitions[1917] = '1917-04-16'; - $this->deviantTransitions[1918] = '1918-04-15'; - $this->deviantTransitions[1940] = '1940-04-01'; - $this->deviantTransitions[1946] = '1946-04-14'; - $this->deviantTransitions[1947] = '1947-04-06'; - $this->deviantTransitions[1948] = '1948-04-18'; - $this->deviantTransitions[1949] = '1949-04-10'; - } - } - - /** - * Tests the holiday defined in this test. - * - * @throws \Exception - */ - public function testSummerTime(): void - { - $this->assertNotHoliday(self::REGION, self::HOLIDAY, $this->randomYearFromArray($this->unobservedYears)); - - $year = $this->randomYearFromArray($this->observedYears); - $expectedDate = new \DateTime("last sunday of march {$year}", new \DateTimeZone(self::TIMEZONE)); - - if (array_key_exists($year, $this->deviantTransitions)) { - $expectedDate = new \DateTime($this->deviantTransitions[$year], new \DateTimeZone(self::TIMEZONE)); - } - - // Since 1980 Summertime in Denmark starts on the last day of March. In 1980 itself however, it started on April, 6th. - if (1980 === $year) { - $expectedDate = new \DateTime('1980-04-06', new \DateTimeZone(self::TIMEZONE)); - } - - $this->assertHoliday( - self::REGION, - self::HOLIDAY, - $year, - $expectedDate - ); - } - - /** - * Tests the translated name of the holiday defined in this test. - * - * @throws \Exception - */ - public function testTranslation(): void - { - $this->assertTranslatedHolidayName( - self::REGION, - self::HOLIDAY, - $this->randomYearFromArray($this->observedYears), - [self::LOCALE => 'sommertid starter'] - ); - } - - /** - * Tests type of the holiday defined in this test. - * - * @throws \Exception - */ - public function testHolidayType(): void - { - $this->assertHolidayType( - self::REGION, - self::HOLIDAY, - $this->randomYearFromArray($this->observedYears), - Holiday::TYPE_SEASON - ); - } -} diff --git a/tests/Denmark/WinterTimeTest.php b/tests/Denmark/WinterTimeTest.php deleted file mode 100644 index 6f0fd2ed7..000000000 --- a/tests/Denmark/WinterTimeTest.php +++ /dev/null @@ -1,125 +0,0 @@ - - */ - -namespace Yasumi\tests\Denmark; - -use Yasumi\Holiday; - -/** - * Class for testing winter time in Denmark. - * - * @see: https://en.wikipedia.org/wiki/Time_in_the_Danish_Realm#History - */ -final class WinterTimeTest extends DaylightSavingTime -{ - /** The name of the holiday */ - public const HOLIDAY = 'winterTime'; - - /* List of transition dates that deviate from the known/defined rules. - * PHP derives the transition dates from the tz database which appear to - * be different for some dates */ - private array $deviantTransitions = [ - 1916 => '1916-09-30', - 1942 => '1942-11-02', - 1943 => '1943-10-04', - 1944 => '1944-10-02', - 1945 => '1945-08-15', - 1946 => '1946-09-01', - 1947 => '1947-08-10', - 1948 => '1948-08-08', - ]; - - public function __construct() - { - parent::__construct(); - - // no wintertime defined for 1940 - if (false !== ($key = array_search(1940, $this->observedYears, true))) { - unset($this->observedYears[(int) $key]); - } - - // In version 2022f of the tz db, a correction for some years weere made for the wintertime - // transitions. See: https://github.com/eggert/tz/blob/2022f/europe - if (1 === strcmp(\intltz_get_tz_data_version(), '2022f')) { - $this->swapObservation([1918, 1917, 1945, 1946, 1948, 1949]); - - $this->deviantTransitions[1917] = '1917-09-17'; - $this->deviantTransitions[1918] = '1918-09-16'; - $this->deviantTransitions[1945] = '1945-11-18'; - $this->deviantTransitions[1946] = '1946-10-07'; - $this->deviantTransitions[1947] = '1947-10-05'; - $this->deviantTransitions[1948] = '1948-10-03'; - $this->deviantTransitions[1949] = '1949-10-02'; - } - } - - /** - * Tests the holiday defined in this test. - * - * @throws \Exception - */ - public function testWinterTime(): void - { - $this->assertNotHoliday(self::REGION, self::HOLIDAY, $this->randomYearFromArray($this->unobservedYears)); - - $year = $this->randomYearFromArray($this->observedYears); - $expectedDate = new \DateTime("last sunday of september {$year}", new \DateTimeZone(self::TIMEZONE)); - - if ($year >= 1996) { - $expectedDate = new \DateTime("last sunday of october {$year}", new \DateTimeZone(self::TIMEZONE)); - } - - if (array_key_exists($year, $this->deviantTransitions)) { - $expectedDate = new \DateTime($this->deviantTransitions[$year], new \DateTimeZone(self::TIMEZONE)); - } - - $this->assertHoliday( - self::REGION, - self::HOLIDAY, - $year, - $expectedDate - ); - } - - /** - * Tests the translated name of the holiday defined in this test. - * - * @throws \Exception - */ - public function testTranslation(): void - { - $this->assertTranslatedHolidayName( - self::REGION, - self::HOLIDAY, - $this->randomYearFromArray($this->observedYears), - [self::LOCALE => 'sommertid slutter'] - ); - } - - /** - * Tests type of the holiday defined in this test. - * - * @throws \Exception - */ - public function testHolidayType(): void - { - $this->assertHolidayType( - self::REGION, - self::HOLIDAY, - $this->randomYearFromArray($this->observedYears), - Holiday::TYPE_SEASON - ); - } -} diff --git a/tests/Netherlands/NetherlandsTest.php b/tests/Netherlands/NetherlandsTest.php index 1f6871fc8..d6560853d 100644 --- a/tests/Netherlands/NetherlandsTest.php +++ b/tests/Netherlands/NetherlandsTest.php @@ -80,17 +80,6 @@ public function testObservedHolidays(): void ], self::REGION, $this->generateRandomYear(2011, 2014), Holiday::TYPE_OBSERVANCE); } - /** - * Tests if all seasonal holidays in Netherlands are defined by the provider class. - * - * @throws \Exception - */ - public function testSeasonalHolidays(): void - { - $year = $this->generateRandomYear(1978, 2037); - $this->assertDefinedHolidays(['summerTime', 'winterTime'], self::REGION, $year, Holiday::TYPE_SEASON); - } - /** * Tests if all bank holidays in Netherlands are defined by the provider class. */ diff --git a/tests/Netherlands/SummerTimeTest.php b/tests/Netherlands/SummerTimeTest.php deleted file mode 100644 index e847bcbc8..000000000 --- a/tests/Netherlands/SummerTimeTest.php +++ /dev/null @@ -1,155 +0,0 @@ - - */ - -namespace Yasumi\tests\Netherlands; - -use Yasumi\Holiday; - -/** - * Class for testing Summertime in the Netherlands. - */ -final class SummerTimeTest extends DaylightSavingTime -{ - /** The name of the holiday */ - public const HOLIDAY = 'summerTime'; - - /* List of transition dates that deviate from the known/defined rules. - * PHP derives the transition dates from the tz database which are - * different for some years */ - private array $deviantTransitions = [ - 1916 => '1916-04-30', - 1917 => '1917-04-16', - 1919 => '1919-04-07', - 1918 => '1918-04-01', - 1920 => '1920-04-05', - 1921 => '1921-04-04', - 1922 => '1922-03-26', - 1923 => '1923-06-01', - 1924 => '1924-03-30', - 1925 => '1925-06-05', - 1932 => '1932-05-22', - 1937 => '1937-05-22', - 1943 => '1943-03-29', - 1944 => '1944-04-03', - 1945 => '1945-04-02', - ]; - - public function __construct() - { - parent::__construct(); - - // No summertime defined for 1942 - if (false !== ($key = array_search(1942, $this->observedYears, true))) { - unset($this->observedYears[(int) $key]); - } - - // In version 2022f of the tz db, a correction for some years weere made for the summertime - // transitions. See: https://github.com/eggert/tz/blob/2022f/europe - if (1 === strcmp(\intltz_get_tz_data_version(), '2022f')) { - $this->swapObservation([1946]); - - $this->deviantTransitions[1918] = '1918-04-15'; - $this->deviantTransitions[1919] = '1919-03-01'; - $this->deviantTransitions[1920] = '1920-02-14'; - $this->deviantTransitions[1921] = '1921-03-14'; - $this->deviantTransitions[1922] = '1922-03-25'; - $this->deviantTransitions[1923] = '1923-04-21'; - $this->deviantTransitions[1924] = '1924-03-29'; - $this->deviantTransitions[1925] = '1925-04-04'; - $this->deviantTransitions[1926] = '1926-04-17'; - $this->deviantTransitions[1927] = '1927-04-09'; - $this->deviantTransitions[1928] = '1928-04-14'; - $this->deviantTransitions[1929] = '1929-04-21'; - $this->deviantTransitions[1931] = '1931-04-19'; - $this->deviantTransitions[1930] = '1930-04-13'; - $this->deviantTransitions[1932] = '1932-04-03'; - $this->deviantTransitions[1933] = '1933-03-26'; - $this->deviantTransitions[1934] = '1934-04-08'; - $this->deviantTransitions[1935] = '1935-03-31'; - $this->deviantTransitions[1936] = '1936-04-19'; - $this->deviantTransitions[1937] = '1937-04-04'; - $this->deviantTransitions[1938] = '1938-03-27'; - $this->deviantTransitions[1939] = '1939-04-16'; - $this->deviantTransitions[1940] = '1940-02-25'; - $this->deviantTransitions[1946] = '1946-05-19'; - } - } - - /** - * Tests Summertime. - * - * @throws \Exception - */ - public function testSummertime(): void - { - $this->assertNotHoliday(self::REGION, self::HOLIDAY, $this->randomYearFromArray($this->unobservedYears)); - - $year = $this->randomYearFromArray($this->observedYears); - $expected = "first sunday of april {$year}"; - - if ($year >= 1981) { - $expected = "last sunday of march {$year}"; - } - - if ($year >= 1943 && $year < 1981) { - $expected = "first sunday of april {$year}"; - } - - if ($year >= 1922 && $year < 1943) { - $expected = "may 15th {$year}"; - } - - if (array_key_exists($year, $this->deviantTransitions)) { - $expected = $this->deviantTransitions[$year]; - } - - $this->assertHoliday( - self::REGION, - self::HOLIDAY, - $year, - new \DateTime($expected, new \DateTimeZone(self::TIMEZONE)) - ); - } - - /** - * Tests the translated name of the holiday defined in this test. - * - * @throws \Exception - */ - public function testTranslation(): void - { - $this->assertTranslatedHolidayName( - self::REGION, - self::HOLIDAY, - $this->randomYearFromArray($this->observedYears), - [self::LOCALE => 'zomertijd'] - ); - } - - /** - * Tests type of the holiday defined in this test. - * - * @throws \Exception - */ - public function testHolidayType(): void - { - $this->assertHolidayType( - self::REGION, - self::HOLIDAY, - $this->randomYearFromArray($this->observedYears), - Holiday::TYPE_SEASON - ); - } -} diff --git a/tests/Netherlands/WinterTimeTest.php b/tests/Netherlands/WinterTimeTest.php deleted file mode 100644 index 6cee43719..000000000 --- a/tests/Netherlands/WinterTimeTest.php +++ /dev/null @@ -1,130 +0,0 @@ - - */ - -namespace Yasumi\tests\Netherlands; - -use Yasumi\Holiday; - -/** - * Class for testing Wintertime in the Netherlands. - */ -final class WinterTimeTest extends DaylightSavingTime -{ - /** The name of the holiday */ - public const HOLIDAY = 'winterTime'; - - /* List of transition dates that deviate from the known/defined rules. - * PHP derives the transition dates from the tz database which are - * different for some years */ - private array $deviantTransitions = [ - 1916 => '1916-09-30', - 1917 => '1917-09-17', - 1922 => '1922-10-08', - 1933 => '1933-10-08', - 1939 => '1939-10-08', - 1942 => '1942-11-02', - 1943 => '1943-10-04', - 1944 => '1944-10-02', - 1945 => '1945-09-16', - 1978 => '1978-10-01', - ]; - - public function __construct() - { - parent::__construct(); - - // No wintertime defined for 1940 - if (false !== ($key = array_search(1940, $this->observedYears, true))) { - unset($this->observedYears[(int) $key]); - } - - // In version 2022f of the tz db, a correction for some years weere made for the wintertime - // transitions. See: https://github.com/eggert/tz/blob/2022f/europe - if (1 === strcmp(\intltz_get_tz_data_version(), '2022f')) { - $this->swapObservation([1946]); - - $this->deviantTransitions[1918] = '1918-09-16'; - $this->deviantTransitions[1919] = '1919-10-04'; - $this->deviantTransitions[1920] = '1920-10-23'; - $this->deviantTransitions[1921] = '1921-10-25'; - $this->deviantTransitions[1922] = '1922-10-07'; - $this->deviantTransitions[1923] = '1923-10-06'; - $this->deviantTransitions[1924] = '1924-10-04'; - $this->deviantTransitions[1925] = '1925-10-03'; - $this->deviantTransitions[1926] = '1926-10-02'; - $this->deviantTransitions[1927] = '1927-10-01'; - $this->deviantTransitions[1939] = '1939-11-19'; - $this->deviantTransitions[1944] = '1944-09-17'; - $this->deviantTransitions[1946] = '1946-10-07'; - } - } - - /** - * Tests Wintertime. - * - * @throws \Exception - */ - public function testWintertime(): void - { - $this->assertNotHoliday(self::REGION, self::HOLIDAY, $this->randomYearFromArray($this->unobservedYears)); - - $year = $this->randomYearFromArray($this->observedYears); - $isObserved = in_array($year, $this->observedYears); - - if (true == $isObserved) { - if ($year >= 1996) { - $expected = "last sunday of october {$year}"; - } elseif ($year >= 1977) { - $expected = "last sunday of september {$year}"; - } elseif ($year >= 1922) { - $expected = "first sunday of october {$year}"; - } else { - $expected = "last monday of september {$year}"; - } - } else { - $expected = $this->deviantTransitions[$year]; - } - } - - /** - * Tests the translated name of the holiday defined in this test. - * - * @throws \Exception - */ - public function testTranslation(): void - { - $this->assertTranslatedHolidayName( - self::REGION, - self::HOLIDAY, - $this->randomYearFromArray($this->observedYears), - [self::LOCALE => 'wintertijd'] - ); - } - - /** - * Tests type of the holiday defined in this test. - * - * @throws \Exception - */ - public function testHolidayType(): void - { - $this->assertHolidayType( - self::REGION, - self::HOLIDAY, - $this->randomYearFromArray($this->observedYears), - Holiday::TYPE_SEASON - ); - } -}