startOfTomorrow.js 984 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import { constructFrom } from "./constructFrom.js";
  2. import { constructNow } from "./constructNow.js";
  3. /**
  4. * The {@link startOfTomorrow} function options.
  5. */
  6. /**
  7. * @name startOfTomorrow
  8. * @category Day Helpers
  9. * @summary Return the start of tomorrow.
  10. * @pure false
  11. *
  12. * @typeParam ContextDate - The `Date` type of the context function.
  13. *
  14. * @param options - An object with options
  15. *
  16. * @returns The start of tomorrow
  17. *
  18. * @description
  19. * Return the start of tomorrow.
  20. *
  21. * @example
  22. * // If today is 6 October 2014:
  23. * const result = startOfTomorrow()
  24. * //=> Tue Oct 7 2014 00:00:00
  25. */
  26. export function startOfTomorrow(options) {
  27. const now = constructNow(options?.in);
  28. const year = now.getFullYear();
  29. const month = now.getMonth();
  30. const day = now.getDate();
  31. const date = constructFrom(options?.in, 0);
  32. date.setFullYear(year, month, day + 1);
  33. date.setHours(0, 0, 0, 0);
  34. return date;
  35. }
  36. // Fallback for modularized imports:
  37. export default startOfTomorrow;