1 | import { constructFrom } from "./constructFrom.js";
|
2 | import { constructNow } from "./constructNow.js";
|
3 | import { 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 | */
|
30 | export 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:
|
38 | export default isThisISOWeek;
|