UNPKG

691 BJavaScriptView Raw
1import { toDate } from "./toDate.js";
2
3/**
4 * @name isEqual
5 * @category Common Helpers
6 * @summary Are the given dates equal?
7 *
8 * @description
9 * Are the given dates equal?
10 *
11 * @param dateLeft - The first date to compare
12 * @param dateRight - The second date to compare
13 *
14 * @returns The dates are equal
15 *
16 * @example
17 * // Are 2 July 2014 06:30:45.000 and 2 July 2014 06:30:45.500 equal?
18 * const result = isEqual(
19 * new Date(2014, 6, 2, 6, 30, 45, 0),
20 * new Date(2014, 6, 2, 6, 30, 45, 500)
21 * )
22 * //=> false
23 */
24export function isEqual(leftDate, rightDate) {
25 return +toDate(leftDate) === +toDate(rightDate);
26}
27
28// Fallback for modularized imports:
29export default isEqual;