UNPKG

963 BTypeScriptView Raw
1import type { Day } from "./types.js";
2/**
3 * @name nextDay
4 * @category Weekday Helpers
5 * @summary When is the next day of the week?
6 *
7 * @description
8 * When is the next day of the week? 0-6 the day of the week, 0 represents Sunday.
9 *
10 * @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).
11 *
12 * @param date - The date to check
13 * @param day - day of the week
14 *
15 * @returns The date is the next day of week
16 *
17 * @example
18 * // When is the next Monday after Mar, 20, 2020?
19 * const result = nextDay(new Date(2020, 2, 20), 1)
20 * //=> Mon Mar 23 2020 00:00:00
21 *
22 * @example
23 * // When is the next Tuesday after Mar, 21, 2020?
24 * const result = nextDay(new Date(2020, 2, 21), 2)
25 * //=> Tue Mar 24 2020 00:00:00
26 */
27export declare function nextDay<DateType extends Date>(
28 date: DateType | number | string,
29 day: Day,
30): DateType;