index.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = isSameISOWeekYear;
  6. var _index = _interopRequireDefault(require("../startOfISOWeekYear/index.js"));
  7. var _index2 = _interopRequireDefault(require("../_lib/requiredArgs/index.js"));
  8. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9. /**
  10. * @name isSameISOWeekYear
  11. * @category ISO Week-Numbering Year Helpers
  12. * @summary Are the given dates in the same ISO week-numbering year?
  13. *
  14. * @description
  15. * Are the given dates in the same ISO week-numbering year?
  16. *
  17. * ISO week-numbering year: http://en.wikipedia.org/wiki/ISO_week_date
  18. *
  19. * ### v2.0.0 breaking changes:
  20. *
  21. * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
  22. *
  23. * - The function was renamed from `isSameISOYear` to `isSameISOWeekYear`.
  24. * "ISO week year" is short for [ISO week-numbering year](https://en.wikipedia.org/wiki/ISO_week_date).
  25. * This change makes the name consistent with
  26. * locale-dependent week-numbering year helpers, e.g., `getWeekYear`.
  27. *
  28. * @param {Date|Number} dateLeft - the first date to check
  29. * @param {Date|Number} dateRight - the second date to check
  30. * @returns {Boolean} the dates are in the same ISO week-numbering year
  31. * @throws {TypeError} 2 arguments required
  32. *
  33. * @example
  34. * // Are 29 December 2003 and 2 January 2005 in the same ISO week-numbering year?
  35. * var result = isSameISOWeekYear(new Date(2003, 11, 29), new Date(2005, 0, 2))
  36. * //=> true
  37. */
  38. function isSameISOWeekYear(dirtyDateLeft, dirtyDateRight) {
  39. (0, _index2.default)(2, arguments);
  40. var dateLeftStartOfYear = (0, _index.default)(dirtyDateLeft);
  41. var dateRightStartOfYear = (0, _index.default)(dirtyDateRight);
  42. return dateLeftStartOfYear.getTime() === dateRightStartOfYear.getTime();
  43. }
  44. module.exports = exports.default;