eachMonthOfInterval.d.mts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import type { Interval, StepOptions } from "./types.js";
  2. /**
  3. * The {@link eachMonthOfInterval} function options.
  4. */
  5. export interface EachMonthOfIntervalOptions extends StepOptions {}
  6. /**
  7. * @name eachMonthOfInterval
  8. * @category Interval Helpers
  9. * @summary Return the array of months within the specified time interval.
  10. *
  11. * @description
  12. * Return the array of months within the specified time interval.
  13. *
  14. * @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).
  15. *
  16. * @param interval - The interval
  17. *
  18. * @returns The array with starts of months from the month of the interval start to the month of the interval end
  19. *
  20. * @example
  21. * // Each month between 6 February 2014 and 10 August 2014:
  22. * const result = eachMonthOfInterval({
  23. * start: new Date(2014, 1, 6),
  24. * end: new Date(2014, 7, 10)
  25. * })
  26. * //=> [
  27. * // Sat Feb 01 2014 00:00:00,
  28. * // Sat Mar 01 2014 00:00:00,
  29. * // Tue Apr 01 2014 00:00:00,
  30. * // Thu May 01 2014 00:00:00,
  31. * // Sun Jun 01 2014 00:00:00,
  32. * // Tue Jul 01 2014 00:00:00,
  33. * // Fri Aug 01 2014 00:00:00
  34. * // ]
  35. */
  36. export declare function eachMonthOfInterval<DateType extends Date>(
  37. interval: Interval<DateType>,
  38. options?: EachMonthOfIntervalOptions,
  39. ): DateType[];