Blame view

天文台pc/tianwentai-ui/node_modules/date-fns/isSameISOWeekYear.js 1.18 KB
bc518174   王天杨   提交两个项目文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
  "use strict";
  exports.isSameISOWeekYear = isSameISOWeekYear;
  var _index = require("./startOfISOWeekYear.js");
  
  /**
   * @name isSameISOWeekYear
   * @category ISO Week-Numbering Year Helpers
   * @summary Are the given dates in the same ISO week-numbering year?
   *
   * @description
   * Are the given dates in the same ISO week-numbering year?
   *
   * ISO week-numbering year: http://en.wikipedia.org/wiki/ISO_week_date
   *
   * @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).
   *
   * @param dateLeft - The first date to check
   * @param dateRight - The second date to check
   *
   * @returns The dates are in the same ISO week-numbering year
   *
   * @example
   * // Are 29 December 2003 and 2 January 2005 in the same ISO week-numbering year?
   * const result = isSameISOWeekYear(new Date(2003, 11, 29), new Date(2005, 0, 2))
   * //=> true
   */
  function isSameISOWeekYear(dateLeft, dateRight) {
    const dateLeftStartOfYear = (0, _index.startOfISOWeekYear)(dateLeft);
    const dateRightStartOfYear = (0, _index.startOfISOWeekYear)(dateRight);
  
    return +dateLeftStartOfYear === +dateRightStartOfYear;
  }