From aabb0b73dbe9d79f4cb1f0ddb8cf96fea5fb58e5 Mon Sep 17 00:00:00 2001 From: Vlasta Neubauer Date: Tue, 3 Dec 2019 19:17:09 +0100 Subject: [PATCH] Fix 31.12. bug on DayOfYear --- src/Time/Interval/DayOfYearInterval.php | 2 +- tests/src/Time/Interval/DayOfYearInterval.phpt | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Time/Interval/DayOfYearInterval.php b/src/Time/Interval/DayOfYearInterval.php index cd2dde1c..1422904a 100644 --- a/src/Time/Interval/DayOfYearInterval.php +++ b/src/Time/Interval/DayOfYearInterval.php @@ -51,7 +51,7 @@ public function __construct(DayOfYear $start, DayOfYear $end) $startNumber = $start->getNumber(); $endNumber = $end->getNumber(); - if ($startNumber >= DayOfYear::MAX_NUMBER) { + if ($startNumber > DayOfYear::MAX_NUMBER) { $startNumber %= DayOfYear::MAX_NUMBER; $start = $start->normalize(); } diff --git a/tests/src/Time/Interval/DayOfYearInterval.phpt b/tests/src/Time/Interval/DayOfYearInterval.phpt index bfea2d51..6139a827 100644 --- a/tests/src/Time/Interval/DayOfYearInterval.phpt +++ b/tests/src/Time/Interval/DayOfYearInterval.phpt @@ -111,6 +111,17 @@ Assert::true($interval->intersects($i(15, 23))); Assert::false($interval->intersects($i(1, 5))); Assert::false($interval->intersects($empty)); + +$i1 = new DayOfYearInterval( + DayOfYear::createFromMonthAndDay(12, 31), + DayOfYear::createFromMonthAndDay(1, 1), +); +$i2 = new DayOfYearInterval( + DayOfYear::createFromMonthAndDay(12, 31), + DayOfYear::createFromMonthAndDay(1, 3), +); +Assert::true($i1->intersects($i2)); + // touches() Assert::true($interval->touches($i(1, 9))); Assert::true($interval->touches($i(21, 23)));