UNPKG

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