eachWeekendOfInterval.d.cts 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import type { ContextOptions, Interval } from "./types.js";
  2. /**
  3. * The {@link eachWeekendOfInterval} function options.
  4. */
  5. export interface EachWeekendOfIntervalOptions<DateType extends Date = Date>
  6. extends ContextOptions<DateType> {}
  7. /**
  8. * The {@link eachWeekendOfInterval} function result type.
  9. */
  10. export type EachWeekendOfIntervalResult<
  11. IntervalType extends Interval,
  12. Options extends EachWeekendOfIntervalOptions | undefined,
  13. > = Array<
  14. Options extends EachWeekendOfIntervalOptions<infer DateType>
  15. ? DateType
  16. : IntervalType["start"] extends Date
  17. ? IntervalType["start"]
  18. : IntervalType["end"] extends Date
  19. ? IntervalType["end"]
  20. : Date
  21. >;
  22. /**
  23. * @name eachWeekendOfInterval
  24. * @category Interval Helpers
  25. * @summary List all the Saturdays and Sundays in the given date interval.
  26. *
  27. * @description
  28. * Get all the Saturdays and Sundays in the given date interval.
  29. *
  30. * @typeParam IntervalType - Interval type.
  31. * @typeParam Options - Options type.
  32. *
  33. * @param interval - The given interval
  34. * @param options - An object with options
  35. *
  36. * @returns An array containing all the Saturdays and Sundays
  37. *
  38. * @example
  39. * // Lists all Saturdays and Sundays in the given date interval
  40. * const result = eachWeekendOfInterval({
  41. * start: new Date(2018, 8, 17),
  42. * end: new Date(2018, 8, 30)
  43. * })
  44. * //=> [
  45. * // Sat Sep 22 2018 00:00:00,
  46. * // Sun Sep 23 2018 00:00:00,
  47. * // Sat Sep 29 2018 00:00:00,
  48. * // Sun Sep 30 2018 00:00:00
  49. * // ]
  50. */
  51. export declare function eachWeekendOfInterval<
  52. IntervalType extends Interval,
  53. Options extends EachWeekendOfIntervalOptions | undefined = undefined,
  54. >(
  55. interval: IntervalType,
  56. options?: Options,
  57. ): EachWeekendOfIntervalResult<IntervalType, Options>;