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