eachWeekOfInterval.d.ts 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import type {
  2. Interval,
  3. LocalizedOptions,
  4. StepOptions,
  5. WeekOptions,
  6. } from "./types.js";
  7. /**
  8. * The {@link eachWeekOfInterval} function options.
  9. */
  10. export interface EachWeekOfIntervalOptions
  11. extends StepOptions,
  12. WeekOptions,
  13. LocalizedOptions<"options"> {}
  14. /**
  15. * @name eachWeekOfInterval
  16. * @category Interval Helpers
  17. * @summary Return the array of weeks within the specified time interval.
  18. *
  19. * @description
  20. * Return the array of weeks within the specified time interval.
  21. *
  22. * @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).
  23. *
  24. * @param interval - The interval.
  25. * @param options - An object with options.
  26. *
  27. * @returns The array with starts of weeks from the week of the interval start to the week of the interval end
  28. *
  29. * @example
  30. * // Each week within interval 6 October 2014 - 23 November 2014:
  31. * const result = eachWeekOfInterval({
  32. * start: new Date(2014, 9, 6),
  33. * end: new Date(2014, 10, 23)
  34. * })
  35. * //=> [
  36. * // Sun Oct 05 2014 00:00:00,
  37. * // Sun Oct 12 2014 00:00:00,
  38. * // Sun Oct 19 2014 00:00:00,
  39. * // Sun Oct 26 2014 00:00:00,
  40. * // Sun Nov 02 2014 00:00:00,
  41. * // Sun Nov 09 2014 00:00:00,
  42. * // Sun Nov 16 2014 00:00:00,
  43. * // Sun Nov 23 2014 00:00:00
  44. * // ]
  45. */
  46. export declare function eachWeekOfInterval<DateType extends Date>(
  47. interval: Interval<DateType>,
  48. options?: EachWeekOfIntervalOptions,
  49. ): DateType[];