From 31cb6d0726fd6ab17e70a6a933bcc37c5f1a2cce Mon Sep 17 00:00:00 2001 From: "r.chassat" Date: Mon, 20 Nov 2023 23:09:15 +0100 Subject: [PATCH] Fixes : - Easter day calculation rounding for the lunar correction when not using calendar extension - added some phpunit test that checks cases that was incorrect before --- src/Yasumi/Provider/ChristianHolidays.php | 2 +- tests/Belgium/EasterTest.php | 7 +++++++ tests/France/EasterMondayTest.php | 7 +++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Yasumi/Provider/ChristianHolidays.php b/src/Yasumi/Provider/ChristianHolidays.php index 5af2d1e9b..af7ed8dd2 100644 --- a/src/Yasumi/Provider/ChristianHolidays.php +++ b/src/Yasumi/Provider/ChristianHolidays.php @@ -358,7 +358,7 @@ protected function calculateEaster(int $year, string $timezone): \DateTimeInterf } $solar = (int) (($year - 1600) / 100) - (int) (($year - 1600) / 400); // The solar correction - $lunar = (int) (($year - 1400) / 100 * 8 / 25); // The lunar correction + $lunar = (int) (((int) (($year - 1400) / 100) * 8) / 25); // The lunar correction $pfm = (3 - (11 * $golden) + $solar - $lunar) % 30; // Uncorrected date of the Paschal full moon } diff --git a/tests/Belgium/EasterTest.php b/tests/Belgium/EasterTest.php index 2b28af1f8..dfe74c83e 100644 --- a/tests/Belgium/EasterTest.php +++ b/tests/Belgium/EasterTest.php @@ -41,6 +41,13 @@ public function testEaster(): void $year, new \DateTime("{$year}-4-4", new \DateTimeZone(self::TIMEZONE)) ); + $year = 2025; + $this->assertHoliday( + self::REGION, + self::HOLIDAY, + $year, + new \DateTime("{$year}-4-20", new \DateTimeZone(self::TIMEZONE)) + ); } /** diff --git a/tests/France/EasterMondayTest.php b/tests/France/EasterMondayTest.php index 42498338d..bcca737d8 100644 --- a/tests/France/EasterMondayTest.php +++ b/tests/France/EasterMondayTest.php @@ -41,6 +41,13 @@ public function testEasterMonday(): void $year, new \DateTime("{$year}-3-28", new \DateTimeZone(self::TIMEZONE)) ); + $year = 2025; + $this->assertHoliday( + self::REGION, + self::HOLIDAY, + $year, + new \DateTime("{$year}-4-21", new \DateTimeZone(self::TIMEZONE)) + ); } /**