addISOWeekYears.js 1.2 KB

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