index.js 1.0 KB

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