index.js 936 B

123456789101112131415161718192021222324252627282930313233
  1. /**
  2. * @name endOfTomorrow
  3. * @category Day Helpers
  4. * @summary Return the end of tomorrow.
  5. * @pure false
  6. *
  7. * @description
  8. * Return the end of tomorrow.
  9. *
  10. * > ⚠️ Please note that this function is not present in the FP submodule as
  11. * > it uses `new Date()` internally hence impure and can't be safely curried.
  12. *
  13. * ### v2.0.0 breaking changes:
  14. *
  15. * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
  16. *
  17. * @returns {Date} the end of tomorrow
  18. *
  19. * @example
  20. * // If today is 6 October 2014:
  21. * const result = endOfTomorrow()
  22. * //=> Tue Oct 7 2014 23:59:59.999
  23. */
  24. export default function endOfTomorrow() {
  25. var now = new Date();
  26. var year = now.getFullYear();
  27. var month = now.getMonth();
  28. var day = now.getDate();
  29. var date = new Date(0);
  30. date.setFullYear(year, month, day + 1);
  31. date.setHours(23, 59, 59, 999);
  32. return date;
  33. }