previousSaturday.js 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. import { previousDay } from "./previousDay.js";
  2. /**
  3. * The {@link previousSaturday} function options.
  4. */
  5. /**
  6. * @name previousSaturday
  7. * @category Weekday Helpers
  8. * @summary When is the previous Saturday?
  9. *
  10. * @description
  11. * When is the previous 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 - The options
  18. *
  19. * @returns The previous Saturday
  20. *
  21. * @example
  22. * // When is the previous Saturday before Jun, 20, 2021?
  23. * const result = previousSaturday(new Date(2021, 5, 20))
  24. * //=> Sat June 19 2021 00:00:00
  25. */
  26. export function previousSaturday(date, options) {
  27. return previousDay(date, 6, options);
  28. }
  29. // Fallback for modularized imports:
  30. export default previousSaturday;