addISOWeekYears.cjs 1.3 KB

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