addISOWeekYears.js 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. "use strict";
  2. exports.addISOWeekYears = addISOWeekYears;
  3. var _index = require("./getISOWeekYear.js");
  4. var _index2 = require("./setISOWeekYear.js");
  5. /**
  6. * @name addISOWeekYears
  7. * @category ISO Week-Numbering Year Helpers
  8. * @summary Add the specified number of ISO week-numbering years to the given date.
  9. *
  10. * @description
  11. * Add the specified number of ISO week-numbering years to the given date.
  12. *
  13. * ISO week-numbering year: http://en.wikipedia.org/wiki/ISO_week_date
  14. *
  15. * @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).
  16. *
  17. * @param date - The date to be changed
  18. * @param amount - The amount of ISO week-numbering years to be added.
  19. *
  20. * @returns The new date with the ISO week-numbering years added
  21. *
  22. * @example
  23. * // Add 5 ISO week-numbering years to 2 July 2010:
  24. * const result = addISOWeekYears(new Date(2010, 6, 2), 5)
  25. * //=> Fri Jn 26 2015 00:00:00
  26. */
  27. function addISOWeekYears(date, amount) {
  28. return (0, _index2.setISOWeekYear)(
  29. date,
  30. (0, _index.getISOWeekYear)(date) + amount,
  31. );
  32. }