UNPKG

776 BJavaScriptView Raw
1import { previousDay } from "./previousDay.mjs";
2
3/**
4 * @name previousSunday
5 * @category Weekday Helpers
6 * @summary When is the previous Sunday?
7 *
8 * @description
9 * When is the previous 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 previous Sunday
16 *
17 * @example
18 * // When is the previous Sunday before Jun, 21, 2021?
19 * const result = previousSunday(new Date(2021, 5, 21))
20 * //=> Sun June 20 2021 00:00:00
21 */
22export function previousSunday(date) {
23 return previousDay(date, 0);
24}
25
26// Fallback for modularized imports:
27export default previousSunday;