isTomorrow.mjs 866 B

123456789101112131415161718192021222324252627282930
  1. import { addDays } from "./addDays.mjs";
  2. import { constructNow } from "./constructNow.mjs";
  3. import { isSameDay } from "./isSameDay.mjs";
  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. * @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 tomorrow
  18. *
  19. * @example
  20. * // If today is 6 October 2014, is 7 October 14:00:00 tomorrow?
  21. * const result = isTomorrow(new Date(2014, 9, 7, 14, 0))
  22. * //=> true
  23. */
  24. export function isTomorrow(date) {
  25. return isSameDay(date, addDays(constructNow(date), 1));
  26. }
  27. // Fallback for modularized imports:
  28. export default isTomorrow;