previousSunday.js 760 B

1234567891011121314151617181920212223242526
  1. "use strict";
  2. exports.previousSunday = previousSunday;
  3. var _index = require("./previousDay.js");
  4. /**
  5. * @name previousSunday
  6. * @category Weekday Helpers
  7. * @summary When is the previous Sunday?
  8. *
  9. * @description
  10. * When is the previous Sunday?
  11. *
  12. * @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).
  13. *
  14. * @param date - The date to start counting from
  15. *
  16. * @returns The previous Sunday
  17. *
  18. * @example
  19. * // When is the previous Sunday before Jun, 21, 2021?
  20. * const result = previousSunday(new Date(2021, 5, 21))
  21. * //=> Sun June 20 2021 00:00:00
  22. */
  23. function previousSunday(date) {
  24. return (0, _index.previousDay)(date, 0);
  25. }