Skip to main content
Very Popular
Go to Latest
function areIntervalsOverlapping
import { areIntervalsOverlapping } from "https://deno.land/x/date_fns@v2.15.0/index.js";

Examples

// For overlapping time intervals: areIntervalsOverlapping( { start: new Date(2014, 0, 10), end: new Date(2014, 0, 20) }, { start: new Date(2014, 0, 17), end: new Date(2014, 0, 21) } ) //=> true

// For non-overlapping time intervals: areIntervalsOverlapping( { start: new Date(2014, 0, 10), end: new Date(2014, 0, 20) }, { start: new Date(2014, 0, 21), end: new Date(2014, 0, 22) } ) //=> false

// For adjacent time intervals: areIntervalsOverlapping( { start: new Date(2014, 0, 10), end: new Date(2014, 0, 20) }, { start: new Date(2014, 0, 20), end: new Date(2014, 0, 30) } ) //=> false

// Using the inclusive option: areIntervalsOverlapping( { start: new Date(2014, 0, 10), end: new Date(2014, 0, 20) }, { start: new Date(2014, 0, 20), end: new Date(2014, 0, 24) } ) //=> false areIntervalsOverlapping( { start: new Date(2014, 0, 10), end: new Date(2014, 0, 20) }, { start: new Date(2014, 0, 20), end: new Date(2014, 0, 24) }, { inclusive: true } ) //=> true

Parameters

dirtyIntervalLeft
  • the first interval to compare. See [Interval]docs/types/Interval
dirtyIntervalRight
  • the second interval to compare. See [Interval]docs/types/Interval
optional
options = [UNSUPPORTED]