UNPKG

850 BTypeScriptView Raw
1/**
2 * @name eachWeekendOfYear
3 * @category Year Helpers
4 * @summary List all the Saturdays and Sundays in the year.
5 *
6 * @description
7 * Get all the Saturdays and Sundays in the year.
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 year
12 *
13 * @returns An array containing all the Saturdays and Sundays
14 *
15 * @example
16 * // Lists all Saturdays and Sundays in the year
17 * const result = eachWeekendOfYear(new Date(2020, 1, 1))
18 * //=> [
19 * // Sat Jan 03 2020 00:00:00,
20 * // Sun Jan 04 2020 00:00:00,
21 * // ...
22 * // Sun Dec 27 2020 00:00:00
23 * // ]
24 * ]
25 */
26export declare function eachWeekendOfYear<DateType extends Date>(
27 date: DateType | number | string,
28): DateType[];