import { isWithinInterval } from "https://deno.land/x/date_fns@v2.12.0/index.js";
Examples
// For the date within the interval:
isWithinInterval(new Date(2014, 0, 3), {
start: new Date(2014, 0, 1),
end: new Date(2014, 0, 7)
})
//=> true
// For the date within the interval: isWithinInterval(new Date(2014, 0, 3), { start: new Date(2014, 0, 1), end: new Date(2014, 0, 7) }) //=> true
// For the date outside of the interval:
isWithinInterval(new Date(2014, 0, 10), {
start: new Date(2014, 0, 1),
end: new Date(2014, 0, 7)
})
//=> false
// For the date outside of the interval: isWithinInterval(new Date(2014, 0, 10), { start: new Date(2014, 0, 1), end: new Date(2014, 0, 7) }) //=> false
// For date equal to interval start:
isWithinInterval(date, { start, end: date }) // => true
// For date equal to interval start: isWithinInterval(date, { start, end: date }) // => true
// For date equal to interval end:
isWithinInterval(date, { start: date, end }) // => true
// For date equal to interval end: isWithinInterval(date, { start: date, end }) // => true