endOfTomorrow.cjs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. "use strict";
  2. exports.endOfTomorrow = endOfTomorrow;
  3. var _index = require("./constructNow.cjs");
  4. /**
  5. * The {@link endOfTomorrow} function options.
  6. */
  7. /**
  8. * @name endOfTomorrow
  9. * @category Day Helpers
  10. * @summary Return the end of tomorrow.
  11. * @pure false
  12. *
  13. * @description
  14. * Return the end of tomorrow.
  15. *
  16. * @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).
  17. * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
  18. *
  19. * @param options - The options
  20. * @returns The end of tomorrow
  21. *
  22. * @example
  23. * // If today is 6 October 2014:
  24. * const result = endOfTomorrow()
  25. * //=> Tue Oct 7 2014 23:59:59.999
  26. */
  27. function endOfTomorrow(options) {
  28. const now = (0, _index.constructNow)(options?.in);
  29. const year = now.getFullYear();
  30. const month = now.getMonth();
  31. const day = now.getDate();
  32. const date = (0, _index.constructNow)(options?.in);
  33. date.setFullYear(year, month, day + 1);
  34. date.setHours(23, 59, 59, 999);
  35. return options?.in ? options.in(date) : date;
  36. }