index.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. "use strict";
  2. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
  3. Object.defineProperty(exports, "__esModule", {
  4. value: true
  5. });
  6. exports.default = isSameISOWeekYear;
  7. var _index = _interopRequireDefault(require("../startOfISOWeekYear/index.js"));
  8. var _index2 = _interopRequireDefault(require("../_lib/requiredArgs/index.js"));
  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. * @param {Date|Number} dateLeft - the first date to check
  20. * @param {Date|Number} dateRight - the second date to check
  21. * @returns {Boolean} the dates are in the same ISO week-numbering year
  22. * @throws {TypeError} 2 arguments required
  23. *
  24. * @example
  25. * // Are 29 December 2003 and 2 January 2005 in the same ISO week-numbering year?
  26. * const result = isSameISOWeekYear(new Date(2003, 11, 29), new Date(2005, 0, 2))
  27. * //=> true
  28. */
  29. function isSameISOWeekYear(dirtyDateLeft, dirtyDateRight) {
  30. (0, _index2.default)(2, arguments);
  31. var dateLeftStartOfYear = (0, _index.default)(dirtyDateLeft);
  32. var dateRightStartOfYear = (0, _index.default)(dirtyDateRight);
  33. return dateLeftStartOfYear.getTime() === dateRightStartOfYear.getTime();
  34. }
  35. module.exports = exports.default;