UNPKG

1.2 kBTypeScriptView Raw
1/**
2 * @name isSameDay
3 * @category Day Helpers
4 * @summary Are the given dates in the same day (and year and month)?
5 *
6 * @description
7 * Are the given dates in the same day (and year and month)?
8 *
9 * @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).
10 *
11 * @param dateLeft - The first date to check
12 * @param dateRight - The second date to check
13
14 * @returns The dates are in the same day (and year and month)
15 *
16 * @example
17 * // Are 4 September 06:00:00 and 4 September 18:00:00 in the same day?
18 * const result = isSameDay(new Date(2014, 8, 4, 6, 0), new Date(2014, 8, 4, 18, 0))
19 * //=> true
20 *
21 * @example
22 * // Are 4 September and 4 October in the same day?
23 * const result = isSameDay(new Date(2014, 8, 4), new Date(2014, 9, 4))
24 * //=> false
25 *
26 * @example
27 * // Are 4 September, 2014 and 4 September, 2015 in the same day?
28 * const result = isSameDay(new Date(2014, 8, 4), new Date(2015, 8, 4))
29 * //=> false
30 */
31export declare function isSameDay<DateType extends Date>(
32 dateLeft: DateType | number | string,
33 dateRight: DateType | number | string,
34): boolean;