UNPKG

1.24 kBTypeScriptView Raw
1/**
2 * @name differenceInCalendarDays
3 * @category Day Helpers
4 * @summary Get the number of calendar days between the given dates.
5 *
6 * @description
7 * Get the number of calendar days between the given dates. This means that the times are removed
8 * from the dates and then the difference in days is calculated.
9 *
10 * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
11 *
12 * @param dateLeft - The later date
13 * @param dateRight - The earlier date
14 *
15 * @returns The number of calendar days
16 *
17 * @example
18 * // How many calendar days are between
19 * // 2 July 2011 23:00:00 and 2 July 2012 00:00:00?
20 * const result = differenceInCalendarDays(
21 * new Date(2012, 6, 2, 0, 0),
22 * new Date(2011, 6, 2, 23, 0)
23 * )
24 * //=> 366
25 * // How many calendar days are between
26 * // 2 July 2011 23:59:00 and 3 July 2011 00:01:00?
27 * const result = differenceInCalendarDays(
28 * new Date(2011, 6, 3, 0, 1),
29 * new Date(2011, 6, 2, 23, 59)
30 * )
31 * //=> 1
32 */
33export declare function differenceInCalendarDays<DateType extends Date>(
34 dateLeft: DateType | number | string,
35 dateRight: DateType | number | string,
36): number;