UNPKG

1.01 kBTypeScriptView Raw
1/**
2 * @name eachWeekendOfMonth
3 * @category Month Helpers
4 * @summary List all the Saturdays and Sundays in the given month.
5 *
6 * @description
7 * Get all the Saturdays and Sundays in the given month.
8 *
9 * @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).
10 *
11 * @param date - The given month
12 *
13 * @returns An array containing all the Saturdays and Sundays
14 *
15 * @example
16 * // Lists all Saturdays and Sundays in the given month
17 * const result = eachWeekendOfMonth(new Date(2022, 1, 1))
18 * //=> [
19 * // Sat Feb 05 2022 00:00:00,
20 * // Sun Feb 06 2022 00:00:00,
21 * // Sat Feb 12 2022 00:00:00,
22 * // Sun Feb 13 2022 00:00:00,
23 * // Sat Feb 19 2022 00:00:00,
24 * // Sun Feb 20 2022 00:00:00,
25 * // Sat Feb 26 2022 00:00:00,
26 * // Sun Feb 27 2022 00:00:00
27 * // ]
28 */
29export declare function eachWeekendOfMonth<DateType extends Date>(
30 date: DateType,
31): DateType[];