previousSunday.js 1.0 KB

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