index.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. "use strict";
  2. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
  3. Object.defineProperty(exports, "__esModule", {
  4. value: true
  5. });
  6. exports.default = isSameISOWeek;
  7. var _index = _interopRequireDefault(require("../isSameWeek/index.js"));
  8. var _index2 = _interopRequireDefault(require("../_lib/requiredArgs/index.js"));
  9. /**
  10. * @name isSameISOWeek
  11. * @category ISO Week Helpers
  12. * @summary Are the given dates in the same ISO week (and year)?
  13. *
  14. * @description
  15. * Are the given dates in the same ISO week (and 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 (and year)
  22. * @throws {TypeError} 2 arguments required
  23. *
  24. * @example
  25. * // Are 1 September 2014 and 7 September 2014 in the same ISO week?
  26. * const result = isSameISOWeek(new Date(2014, 8, 1), new Date(2014, 8, 7))
  27. * //=> true
  28. *
  29. * @example
  30. * // Are 1 September 2014 and 1 September 2015 in the same ISO week?
  31. * const result = isSameISOWeek(new Date(2014, 8, 1), new Date(2015, 8, 1))
  32. * //=> false
  33. */
  34. function isSameISOWeek(dirtyDateLeft, dirtyDateRight) {
  35. (0, _index2.default)(2, arguments);
  36. return (0, _index.default)(dirtyDateLeft, dirtyDateRight, {
  37. weekStartsOn: 1
  38. });
  39. }
  40. module.exports = exports.default;