import toDate from '../toDate/index' ; import requiredArgs from '../_lib/requiredArgs/index' ; import type { Interval } from '../types' ; name category summary description param { Date | Number } date param { Interval } interval returns { Boolean } throws throws throws example example example example export default function isWithinInterval ( dirtyDate , interval ) { requiredArgs ( 2 , arguments ) ; const time = toDate ( dirtyDate ) . getTime ( ) ; const startTime = toDate ( interval . start ) . getTime ( ) ; const endTime = toDate ( interval . end ) . getTime ( ) ; if ( ! ( startTime <= endTime ) ) { throw new RangeError ( 'Invalid interval' ) ; } return time >= startTime && time <= endTime ; }