From d8fb79e5cca1a26d5569e221b1ed4e82d812221b Mon Sep 17 00:00:00 2001 From: tristan Date: Thu, 11 Jun 2026 09:54:05 +0200 Subject: [PATCH] feat(rtt) : add SolidarityDayResolver (Pentecost Monday via computus) --- src/Service/Rtt/SolidarityDayResolver.php | 43 +++++++++++++++++++ .../Service/Rtt/SolidarityDayResolverTest.php | 39 +++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 src/Service/Rtt/SolidarityDayResolver.php create mode 100644 tests/Service/Rtt/SolidarityDayResolverTest.php diff --git a/src/Service/Rtt/SolidarityDayResolver.php b/src/Service/Rtt/SolidarityDayResolver.php new file mode 100644 index 0000000..10c2bab --- /dev/null +++ b/src/Service/Rtt/SolidarityDayResolver.php @@ -0,0 +1,43 @@ +easterSunday($year)->modify('+50 days'); + } + + private function easterSunday(int $year): DateTimeImmutable + { + $a = $year % 19; + $b = intdiv($year, 100); + $c = $year % 100; + $d = intdiv($b, 4); + $e = $b % 4; + $f = intdiv($b + 8, 25); + $g = intdiv($b - $f + 1, 3); + $h = (19 * $a + $b - $d - $g + 15) % 30; + $i = intdiv($c, 4); + $k = $c % 4; + $l = (32 + 2 * $e + 2 * $i - $h - $k) % 7; + $m = intdiv($a + 11 * $h + 22 * $l, 451); + + $month = intdiv($h + $l - 7 * $m + 114, 31); + $day = (($h + $l - 7 * $m + 114) % 31) + 1; + + return new DateTimeImmutable(sprintf('%04d-%02d-%02d', $year, $month, $day)); + } +} diff --git a/tests/Service/Rtt/SolidarityDayResolverTest.php b/tests/Service/Rtt/SolidarityDayResolverTest.php new file mode 100644 index 0000000..215c1a6 --- /dev/null +++ b/tests/Service/Rtt/SolidarityDayResolverTest.php @@ -0,0 +1,39 @@ +pentecostMonday($year)->format('Y-m-d')); + } + + /** + * @return iterable + */ + public static function pentecostCases(): iterable + { + yield '2024' => [2024, '2024-05-20']; + + yield '2025' => [2025, '2025-06-09']; + + yield '2026' => [2026, '2026-05-25']; + } +}