isAfter.js 958 B

1234567891011121314151617181920212223242526272829
  1. "use strict";
  2. exports.isAfter = isAfter;
  3. var _index = require("./toDate.js");
  4. /**
  5. * @name isAfter
  6. * @category Common Helpers
  7. * @summary Is the first date after the second one?
  8. *
  9. * @description
  10. * Is the first date after the second one?
  11. *
  12. * @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).
  13. *
  14. * @param date - The date that should be after the other one to return true
  15. * @param dateToCompare - The date to compare with
  16. *
  17. * @returns The first date is after the second date
  18. *
  19. * @example
  20. * // Is 10 July 1989 after 11 February 1987?
  21. * const result = isAfter(new Date(1989, 6, 10), new Date(1987, 1, 11))
  22. * //=> true
  23. */
  24. function isAfter(date, dateToCompare) {
  25. const _date = (0, _index.toDate)(date);
  26. const _dateToCompare = (0, _index.toDate)(dateToCompare);
  27. return _date.getTime() > _dateToCompare.getTime();
  28. }