isPast.js 547 B

1234567891011121314151617181920212223242526
  1. import { toDate } from "./toDate.js";
  2. /**
  3. * @name isPast
  4. * @category Common Helpers
  5. * @summary Is the given date in the past?
  6. * @pure false
  7. *
  8. * @description
  9. * Is the given date in the past?
  10. *
  11. * @param date - The date to check
  12. *
  13. * @returns The date is in the past
  14. *
  15. * @example
  16. * // If today is 6 October 2014, is 2 July 2014 in the past?
  17. * const result = isPast(new Date(2014, 6, 2))
  18. * //=> true
  19. */
  20. export function isPast(date) {
  21. return +toDate(date) < Date.now();
  22. }
  23. // Fallback for modularized imports:
  24. export default isPast;