UNPKG

1.54 kBTypeScriptView Raw
1import type { ContextOptions, DateArg } from "./types.js";
2/**
3 * The {@link eachWeekendOfMonth} function options.
4 */
5export interface EachWeekendOfMonthOptions<DateType extends Date = Date>
6 extends ContextOptions<DateType> {}
7/**
8 * @name eachWeekendOfMonth
9 * @category Month Helpers
10 * @summary List all the Saturdays and Sundays in the given month.
11 *
12 * @description
13 * Get all the Saturdays and Sundays in the given month.
14 *
15 * @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).
16 * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
17 *
18 * @param date - The given month
19 * @param options - An object with options
20 *
21 * @returns An array containing all the Saturdays and Sundays
22 *
23 * @example
24 * // Lists all Saturdays and Sundays in the given month
25 * const result = eachWeekendOfMonth(new Date(2022, 1, 1))
26 * //=> [
27 * // Sat Feb 05 2022 00:00:00,
28 * // Sun Feb 06 2022 00:00:00,
29 * // Sat Feb 12 2022 00:00:00,
30 * // Sun Feb 13 2022 00:00:00,
31 * // Sat Feb 19 2022 00:00:00,
32 * // Sun Feb 20 2022 00:00:00,
33 * // Sat Feb 26 2022 00:00:00,
34 * // Sun Feb 27 2022 00:00:00
35 * // ]
36 */
37export declare function eachWeekendOfMonth<
38 DateType extends Date,
39 ResultDate extends Date = DateType,
40>(
41 date: DateArg<DateType>,
42 options?: EachWeekendOfMonthOptions<ResultDate>,
43): ResultDate[];