index.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. "use strict";
  2. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
  3. Object.defineProperty(exports, "__esModule", {
  4. value: true
  5. });
  6. exports.default = isFuture;
  7. var _index = _interopRequireDefault(require("../toDate/index.js"));
  8. var _index2 = _interopRequireDefault(require("../_lib/requiredArgs/index.js"));
  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. * @param {Date|Number} date - the date to check
  22. * @returns {Boolean} the date is in the future
  23. * @throws {TypeError} 1 argument required
  24. *
  25. * @example
  26. * // If today is 6 October 2014, is 31 December 2014 in the future?
  27. * const result = isFuture(new Date(2014, 11, 31))
  28. * //=> true
  29. */
  30. function isFuture(dirtyDate) {
  31. (0, _index2.default)(1, arguments);
  32. return (0, _index.default)(dirtyDate).getTime() > Date.now();
  33. }
  34. module.exports = exports.default;