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)));