previousFriday.mjs 776 B

123456789101112131415161718192021222324252627
  1. import { previousDay } from "./previousDay.mjs";
  2. /**
  3. * @name previousFriday
  4. * @category Weekday Helpers
  5. * @summary When is the previous Friday?
  6. *
  7. * @description
  8. * When is the previous Friday?
  9. *
  10. * @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).
  11. *
  12. * @param date - The date to start counting from
  13. *
  14. * @returns The previous Friday
  15. *
  16. * @example
  17. * // When is the previous Friday before Jun, 19, 2021?
  18. * const result = previousFriday(new Date(2021, 5, 19))
  19. * //=> Fri June 18 2021 00:00:00
  20. */
  21. export function previousFriday(date) {
  22. return previousDay(date, 5);
  23. }
  24. // Fallback for modularized imports:
  25. export default previousFriday;