UNPKG

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