nextSaturday.js 1011 B

123456789101112131415161718192021222324252627282930313233
  1. import { nextDay } from "./nextDay.js";
  2. /**
  3. * The {@link nextSaturday} function options.
  4. */
  5. /**
  6. * @name nextSaturday
  7. * @category Weekday Helpers
  8. * @summary When is the next Saturday?
  9. *
  10. * @description
  11. * When is the next Saturday?
  12. *
  13. * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
  14. * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
  15. *
  16. * @param date - The date to start counting from
  17. * @param options - An object with options
  18. *
  19. * @returns The next Saturday
  20. *
  21. * @example
  22. * // When is the next Saturday after Mar, 22, 2020?
  23. * const result = nextSaturday(new Date(2020, 2, 22))
  24. * //=> Sat Mar 28 2020 00:00:00
  25. */
  26. export function nextSaturday(date, options) {
  27. return nextDay(date, 6, options);
  28. }
  29. // Fallback for modularized imports:
  30. export default nextSaturday;