UNPKG

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