UNPKG

993 BJavaScriptView Raw
1import { constructNow } from "./constructNow.mjs";
2import { isSameISOWeek } from "./isSameISOWeek.mjs";
3
4/**
5 * @name isThisISOWeek
6 * @category ISO Week Helpers
7 * @summary Is the given date in the same ISO week as the current date?
8 * @pure false
9 *
10 * @description
11 * Is the given date in the same ISO week as the current date?
12 *
13 * ISO week-numbering year: http://en.wikipedia.org/wiki/ISO_week_date
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 *
17 * @param date - The date to check
18 *
19 * @returns The date is in this ISO week
20 *
21 * @example
22 * // If today is 25 September 2014, is 22 September 2014 in this ISO week?
23 * const result = isThisISOWeek(new Date(2014, 8, 22))
24 * //=> true
25 */
26
27export function isThisISOWeek(date) {
28 return isSameISOWeek(date, constructNow(date));
29}
30
31// Fallback for modularized imports:
32export default isThisISOWeek;