differenceInCalendarISOWeekYears.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. "use strict";
  2. exports.differenceInCalendarISOWeekYears = differenceInCalendarISOWeekYears;
  3. var _index = require("./getISOWeekYear.js");
  4. /**
  5. * @name differenceInCalendarISOWeekYears
  6. * @category ISO Week-Numbering Year Helpers
  7. * @summary Get the number of calendar ISO week-numbering years between the given dates.
  8. *
  9. * @description
  10. * Get the number of calendar ISO week-numbering years between the given dates.
  11. *
  12. * ISO week-numbering year: http://en.wikipedia.org/wiki/ISO_week_date
  13. *
  14. * @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).
  15. *
  16. * @param dateLeft - The later date
  17. * @param dateRight - The earlier date
  18. *
  19. * @returns The number of calendar ISO week-numbering years
  20. *
  21. * @example
  22. * // How many calendar ISO week-numbering years are 1 January 2010 and 1 January 2012?
  23. * const result = differenceInCalendarISOWeekYears(
  24. * new Date(2012, 0, 1),
  25. * new Date(2010, 0, 1)
  26. * )
  27. * //=> 2
  28. */
  29. function differenceInCalendarISOWeekYears(dateLeft, dateRight) {
  30. return (
  31. (0, _index.getISOWeekYear)(dateLeft) - (0, _index.getISOWeekYear)(dateRight)
  32. );
  33. }