isAfter.js 697 B

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