Skip to content

Commit c3be6a4

Browse files
authored
#927: Return null when calling intersection() on abutting Intervals (#928)
1 parent 91c5f87 commit c3be6a4

2 files changed

Lines changed: 3 additions & 7 deletions

File tree

‎src/interval.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ export default class Interval {
429429
const s = this.s > other.s ? this.s : other.s,
430430
e = this.e < other.e ? this.e : other.e;
431431

432-
if (s > e) {
432+
if (s >= e) {
433433
return null;
434434
} else {
435435
return Interval.fromDateTimes(s, e);

‎test/interval/many.test.js‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,8 @@ test("Interval#intersection returns the intersection for overlapping intervals",
111111
).toBeTruthy();
112112
});
113113

114-
test("Interval#intersection returns empty for adjacent intervals", () => {
115-
expect(
116-
todayFrom(5, 8)
117-
.intersection(todayFrom(8, 10))
118-
.isEmpty()
119-
).toBeTruthy();
114+
test("Interval#intersection returns null for adjacent intervals", () => {
115+
expect(todayFrom(5, 8).intersection(todayFrom(8, 10))).toBeNull();
120116
});
121117

122118
test("Interval#intersection returns invalid for invalid intervals", () => {

0 commit comments

Comments
 (0)