index.js 758 B

1234567891011121314151617181920212223242526272829
  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. * @returns {Date} the end of tomorrow
  14. *
  15. * @example
  16. * // If today is 6 October 2014:
  17. * const result = endOfTomorrow()
  18. * //=> Tue Oct 7 2014 23:59:59.999
  19. */
  20. export default function endOfTomorrow() {
  21. var now = new Date();
  22. var year = now.getFullYear();
  23. var month = now.getMonth();
  24. var day = now.getDate();
  25. var date = new Date(0);
  26. date.setFullYear(year, month, day + 1);
  27. date.setHours(23, 59, 59, 999);
  28. return date;
  29. }