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