UNPKG

1.03 kBJavaScriptView Raw
1import { previousDay } from "./previousDay.js";
2
3/**
4 * The {@link previousFriday} function options.
5 */
6
7/**
8 * @name previousFriday
9 * @category Weekday Helpers
10 * @summary When is the previous Friday?
11 *
12 * @description
13 * When is the previous Friday?
14 *
15 * @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).
16 * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
17 *
18 * @param date - The date to start counting from
19 * @param options - The options
20 *
21 * @returns The previous Friday
22 *
23 * @example
24 * // When is the previous Friday before Jun, 19, 2021?
25 * const result = previousFriday(new Date(2021, 5, 19))
26 * //=> Fri June 18 2021 00:00:00
27 */
28export function previousFriday(date, options) {
29 return previousDay(date, 5, options);
30}
31
32// Fallback for modularized imports:
33export default previousFriday;