UNPKG

1.34 kBTypeScriptView Raw
1import type { ContextOptions, DateArg, Interval } from "./types.js";
2/**
3 * The {@link isWithinInterval} function options.
4 */
5export interface IsWithinIntervalOptions extends ContextOptions<Date> {}
6/**
7 * @name isWithinInterval
8 * @category Interval Helpers
9 * @summary Is the given date within the interval?
10 *
11 * @description
12 * Is the given date within the interval? (Including start and end.)
13 *
14 * @param date - The date to check
15 * @param interval - The interval to check
16 * @param options - An object with options
17 *
18 * @returns The date is within the interval
19 *
20 * @example
21 * // For the date within the interval:
22 * isWithinInterval(new Date(2014, 0, 3), {
23 * start: new Date(2014, 0, 1),
24 * end: new Date(2014, 0, 7)
25 * })
26 * // => true
27 *
28 * @example
29 * // For the date outside of the interval:
30 * isWithinInterval(new Date(2014, 0, 10), {
31 * start: new Date(2014, 0, 1),
32 * end: new Date(2014, 0, 7)
33 * })
34 * // => false
35 *
36 * @example
37 * // For date equal to the interval start:
38 * isWithinInterval(date, { start, end: date })
39 * // => true
40 *
41 * @example
42 * // For date equal to the interval end:
43 * isWithinInterval(date, { start: date, end })
44 * // => true
45 */
46export declare function isWithinInterval(
47 date: DateArg<Date> & {},
48 interval: Interval,
49 options?: IsWithinIntervalOptions | undefined,
50): boolean;