index.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = isFuture;
  6. var _index = _interopRequireDefault(require("../toDate/index.js"));
  7. var _index2 = _interopRequireDefault(require("../_lib/requiredArgs/index.js"));
  8. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9. /**
  10. * @name isFuture
  11. * @category Common Helpers
  12. * @summary Is the given date in the future?
  13. * @pure false
  14. *
  15. * @description
  16. * Is the given date in the future?
  17. *
  18. * > ⚠️ Please note that this function is not present in the FP submodule as
  19. * > it uses `Date.now()` internally hence impure and can't be safely curried.
  20. *
  21. * ### v2.0.0 breaking changes:
  22. *
  23. * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
  24. *
  25. * @param {Date|Number} date - the date to check
  26. * @returns {Boolean} the date is in the future
  27. * @throws {TypeError} 1 argument required
  28. *
  29. * @example
  30. * // If today is 6 October 2014, is 31 December 2014 in the future?
  31. * var result = isFuture(new Date(2014, 11, 31))
  32. * //=> true
  33. */
  34. function isFuture(dirtyDate) {
  35. (0, _index2.default)(1, arguments);
  36. return (0, _index.default)(dirtyDate).getTime() > Date.now();
  37. }
  38. module.exports = exports.default;