UNPKG

1.33 kBTypeScriptView Raw
1import type { ContextOptions, DateArg } from "./types.js";
2/**
3 * The {@link differenceInCalendarDays} function options.
4 */
5export interface DifferenceInCalendarDaysOptions extends ContextOptions<Date> {}
6/**
7 * @name differenceInCalendarDays
8 * @category Day Helpers
9 * @summary Get the number of calendar days between the given dates.
10 *
11 * @description
12 * Get the number of calendar days between the given dates. This means that the times are removed
13 * from the dates and then the difference in days is calculated.
14 *
15 * @param laterDate - The later date
16 * @param earlierDate - The earlier date
17 * @param options - The options object
18 *
19 * @returns The number of calendar days
20 *
21 * @example
22 * // How many calendar days are between
23 * // 2 July 2011 23:00:00 and 2 July 2012 00:00:00?
24 * const result = differenceInCalendarDays(
25 * new Date(2012, 6, 2, 0, 0),
26 * new Date(2011, 6, 2, 23, 0)
27 * )
28 * //=> 366
29 * // How many calendar days are between
30 * // 2 July 2011 23:59:00 and 3 July 2011 00:01:00?
31 * const result = differenceInCalendarDays(
32 * new Date(2011, 6, 3, 0, 1),
33 * new Date(2011, 6, 2, 23, 59)
34 * )
35 * //=> 1
36 */
37export declare function differenceInCalendarDays(
38 laterDate: DateArg<Date> & {},
39 earlierDate: DateArg<Date> & {},
40 options?: DifferenceInCalendarDaysOptions | undefined,
41): number;