nextMonday.js 972 B

123456789101112131415161718192021222324252627282930313233
  1. import { nextDay } from "./nextDay.js";
  2. /**
  3. * The {@link nextMonday} function options.
  4. */
  5. /**
  6. * @name nextMonday
  7. * @category Weekday Helpers
  8. * @summary When is the next Monday?
  9. *
  10. * @description
  11. * When is the next Monday?
  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, returned from the context function if 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 Monday
  20. *
  21. * @example
  22. * // When is the next Monday after Mar, 22, 2020?
  23. * const result = nextMonday(new Date(2020, 2, 22))
  24. * //=> Mon Mar 23 2020 00:00:00
  25. */
  26. export function nextMonday(date, options) {
  27. return nextDay(date, 1, options);
  28. }
  29. // Fallback for modularized imports:
  30. export default nextMonday;