isFuture.js 738 B

123456789101112131415161718192021222324252627
  1. "use strict";
  2. exports.isFuture = isFuture;
  3. var _index = require("./toDate.js");
  4. /**
  5. * @name isFuture
  6. * @category Common Helpers
  7. * @summary Is the given date in the future?
  8. * @pure false
  9. *
  10. * @description
  11. * Is the given date in the future?
  12. *
  13. * @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).
  14. *
  15. * @param date - The date to check
  16. *
  17. * @returns The date is in the future
  18. *
  19. * @example
  20. * // If today is 6 October 2014, is 31 December 2014 in the future?
  21. * const result = isFuture(new Date(2014, 11, 31))
  22. * //=> true
  23. */
  24. function isFuture(date) {
  25. return +(0, _index.toDate)(date) > Date.now();
  26. }