diff --git a/src/Time/Interval/NightInterval.php b/src/Time/Interval/NightInterval.php index a49e6596..0370007f 100644 --- a/src/Time/Interval/NightInterval.php +++ b/src/Time/Interval/NightInterval.php @@ -311,6 +311,10 @@ public function compareIntersects(IntersectComparable $other): int */ public function containsValue($date): bool { + if ($this->isEmpty()) { + return false; + } + if (!$date instanceof Date) { $date = Date::createFromDateTimeInterface($date); } diff --git a/tests/src/Time/Interval/NightInterval.phpt b/tests/src/Time/Interval/NightInterval.phpt index b3f7dabd..94316a03 100644 --- a/tests/src/Time/Interval/NightInterval.phpt +++ b/tests/src/Time/Interval/NightInterval.phpt @@ -150,6 +150,7 @@ Assert::false($interval->containsValue($d(21))); Assert::false($interval->containsValue($d(5))); Assert::false($interval->containsValue($d(25))); Assert::true($interval->containsValue(new DateTimeImmutable('2000-01-15'))); +Assert::false($empty->containsValue($d(10))); contains: