index.js 697 B

12345678910111213141516171819202122232425
  1. import requiredArgs from "../_lib/requiredArgs/index.js";
  2. import nextDay from "../nextDay/index.js";
  3. import toDate from "../toDate/index.js";
  4. /**
  5. * @name nextTuesday
  6. * @category Weekday Helpers
  7. * @summary When is the next Tuesday?
  8. *
  9. * @description
  10. * When is the next Tuesday?
  11. *
  12. * @param {Date | number} date - the date to start counting from
  13. * @returns {Date} the next Tuesday
  14. * @throws {TypeError} 1 argument required
  15. *
  16. * @example
  17. * // When is the next Tuesday after Mar, 22, 2020?
  18. * const result = nextTuesday(new Date(2020, 2, 22))
  19. * //=> Tue Mar 24 2020 00:00:00
  20. */
  21. export default function nextTuesday(date) {
  22. requiredArgs(1, arguments);
  23. return nextDay(toDate(date), 2);
  24. }