UNPKG

730 BJavaScriptView Raw
1import { nextDay } from "./nextDay.mjs";
2
3/**
4 * @name nextSunday
5 * @category Weekday Helpers
6 * @summary When is the next Sunday?
7 *
8 * @description
9 * When is the next Sunday?
10 *
11 * @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).
12 *
13 * @param date - The date to start counting from
14 *
15 * @returns The next Sunday
16 *
17 * @example
18 * // When is the next Sunday after Mar, 22, 2020?
19 * const result = nextSunday(new Date(2020, 2, 22))
20 * //=> Sun Mar 29 2020 00:00:00
21 */
22export function nextSunday(date) {
23 return nextDay(date, 0);
24}
25
26// Fallback for modularized imports:
27export default nextSunday;