Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 

32 righe
1.0 KiB

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