Rocky_Mountain_Vending/.pnpm-store/v10/files/a1/9fc18f046319e32d229bf18cf126ee90a5a7a2f2a5e7f3d4a27dab93f85fe0dabec13c2db533dd6b40a073ea54caf04a7b8cec05cc52fe962e35c938c838d4
DMleadgen 46d973904b
Initial commit: Rocky Mountain Vending website
Next.js website for Rocky Mountain Vending company featuring:
- Product catalog with Stripe integration
- Service areas and parts pages
- Admin dashboard with Clerk authentication
- SEO optimized pages with JSON-LD structured data

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 16:22:15 -07:00

58 lines
1.4 KiB
Text

import { toDate } from "./toDate.js";
/**
* The {@link isWithinInterval} function options.
*/
/**
* @name isWithinInterval
* @category Interval Helpers
* @summary Is the given date within the interval?
*
* @description
* Is the given date within the interval? (Including start and end.)
*
* @param date - The date to check
* @param interval - The interval to check
* @param options - An object with options
*
* @returns The date is within the interval
*
* @example
* // 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
*
* @example
* // 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
*
* @example
* // For date equal to the interval start:
* isWithinInterval(date, { start, end: date })
* // => true
*
* @example
* // For date equal to the interval end:
* isWithinInterval(date, { start: date, end })
* // => true
*/
export function isWithinInterval(date, interval, options) {
const time = +toDate(date, options?.in);
const [startTime, endTime] = [
+toDate(interval.start, options?.in),
+toDate(interval.end, options?.in),
].sort((a, b) => a - b);
return time >= startTime && time <= endTime;
}
// Fallback for modularized imports:
export default isWithinInterval;