eachWeekendOfInterval.d.ts 1.0 KB

12345678910111213141516171819202122232425262728293031
  1. import type { Interval } from "./types.js";
  2. /**
  3. * @name eachWeekendOfInterval
  4. * @category Interval Helpers
  5. * @summary List all the Saturdays and Sundays in the given date interval.
  6. *
  7. * @description
  8. * Get all the Saturdays and Sundays in the given date interval.
  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 interval - The given interval
  13. *
  14. * @returns An array containing all the Saturdays and Sundays
  15. *
  16. * @example
  17. * // Lists all Saturdays and Sundays in the given date interval
  18. * const result = eachWeekendOfInterval({
  19. * start: new Date(2018, 8, 17),
  20. * end: new Date(2018, 8, 30)
  21. * })
  22. * //=> [
  23. * // Sat Sep 22 2018 00:00:00,
  24. * // Sun Sep 23 2018 00:00:00,
  25. * // Sat Sep 29 2018 00:00:00,
  26. * // Sun Sep 30 2018 00:00:00
  27. * // ]
  28. */
  29. export declare function eachWeekendOfInterval<DateType extends Date>(
  30. interval: Interval<DateType>,
  31. ): DateType[];