index.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = differenceInCalendarISOWeekYears;
  6. var _index = _interopRequireDefault(require("../getISOWeekYear/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 differenceInCalendarISOWeekYears
  11. * @category ISO Week-Numbering Year Helpers
  12. * @summary Get the number of calendar ISO week-numbering years between the given dates.
  13. *
  14. * @description
  15. * Get the number of calendar ISO week-numbering years between the given dates.
  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 `differenceInCalendarISOYears` to `differenceInCalendarISOWeekYears`.
  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., `addWeekYears`.
  27. *
  28. * @param {Date|Number} dateLeft - the later date
  29. * @param {Date|Number} dateRight - the earlier date
  30. * @returns {Number} the number of calendar ISO week-numbering years
  31. * @throws {TypeError} 2 arguments required
  32. *
  33. * @example
  34. * // How many calendar ISO week-numbering years are 1 January 2010 and 1 January 2012?
  35. * const result = differenceInCalendarISOWeekYears(
  36. * new Date(2012, 0, 1),
  37. * new Date(2010, 0, 1)
  38. * )
  39. * //=> 2
  40. */
  41. function differenceInCalendarISOWeekYears(dirtyDateLeft, dirtyDateRight) {
  42. (0, _index2.default)(2, arguments);
  43. return (0, _index.default)(dirtyDateLeft) - (0, _index.default)(dirtyDateRight);
  44. }
  45. module.exports = exports.default;