UNPKG

1.18 kBJavaScriptView Raw
1"use strict";
2exports.isSameISOWeek = isSameISOWeek;
3var _index = require("./isSameWeek.js");
4
5/**
6 * @name isSameISOWeek
7 * @category ISO Week Helpers
8 * @summary Are the given dates in the same ISO week (and year)?
9 *
10 * @description
11 * Are the given dates in the same ISO week (and year)?
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 dateLeft - The first date to check
18 * @param dateRight - The second date to check
19 *
20 * @returns The dates are in the same ISO week (and year)
21 *
22 * @example
23 * // Are 1 September 2014 and 7 September 2014 in the same ISO week?
24 * const result = isSameISOWeek(new Date(2014, 8, 1), new Date(2014, 8, 7))
25 * //=> true
26 *
27 * @example
28 * // Are 1 September 2014 and 1 September 2015 in the same ISO week?
29 * const result = isSameISOWeek(new Date(2014, 8, 1), new Date(2015, 8, 1))
30 * //=> false
31 */
32function isSameISOWeek(dateLeft, dateRight) {
33 return (0, _index.isSameWeek)(dateLeft, dateRight, { weekStartsOn: 1 });
34}