UNPKG

697 BJavaScriptView Raw
1import { toDate } from "./toDate.js";
2
3/**
4 * @name isAfter
5 * @category Common Helpers
6 * @summary Is the first date after the second one?
7 *
8 * @description
9 * Is the first date after the second one?
10 *
11 * @param date - The date that should be after the other one to return true
12 * @param dateToCompare - The date to compare with
13 *
14 * @returns The first date is after the second date
15 *
16 * @example
17 * // Is 10 July 1989 after 11 February 1987?
18 * const result = isAfter(new Date(1989, 6, 10), new Date(1987, 1, 11))
19 * //=> true
20 */
21export function isAfter(date, dateToCompare) {
22 return +toDate(date) > +toDate(dateToCompare);
23}
24
25// Fallback for modularized imports:
26export default isAfter;