startOfTomorrow.mjs 665 B

123456789101112131415161718192021222324252627282930
  1. /**
  2. * @name startOfTomorrow
  3. * @category Day Helpers
  4. * @summary Return the start of tomorrow.
  5. * @pure false
  6. *
  7. * @description
  8. * Return the start of tomorrow.
  9. *
  10. * @returns The start of tomorrow
  11. *
  12. * @example
  13. * // If today is 6 October 2014:
  14. * const result = startOfTomorrow()
  15. * //=> Tue Oct 7 2014 00:00:00
  16. */
  17. export function startOfTomorrow() {
  18. const now = new Date();
  19. const year = now.getFullYear();
  20. const month = now.getMonth();
  21. const day = now.getDate();
  22. const date = new Date(0);
  23. date.setFullYear(year, month, day + 1);
  24. date.setHours(0, 0, 0, 0);
  25. return date;
  26. }
  27. // Fallback for modularized imports:
  28. export default startOfTomorrow;