UNPKG

react-native-plain-calendar

Version:
15 lines (14 loc) 501 B
import * as dateFns from 'date-fns'; import { isBetween } from './isBetween'; import { withArray } from './withArray'; export function isWithinRange(date, startDate, endDate) { let start = startDate; let end = endDate; if (dateFns.isAfter(start, end)) { [start, end] = [end, start]; } return isBetween(start, end, date); } export function isWithinRangeWithArray(dates, startDate, endDate) { return withArray(dates, (date) => isWithinRange(date, startDate, endDate)); }