Skip to content

Commit

Permalink
Fix 31.12. bug on DayOfYear
Browse files Browse the repository at this point in the history
  • Loading branch information
paranoiq committed Dec 3, 2019
1 parent fa49510 commit aabb0b7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Time/Interval/DayOfYearInterval.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
11 changes: 11 additions & 0 deletions tests/src/Time/Interval/DayOfYearInterval.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
Expand Down

0 comments on commit aabb0b7

Please sign in to comment.