UNPKG

1.27 kBJavaScriptView Raw
1import { getISOWeekYear } from "./getISOWeekYear.js";
2import { setISOWeekYear } from "./setISOWeekYear.js";
3
4/**
5 * The {@link addISOWeekYears} function options.
6 */
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 */
31export function addISOWeekYears(date, amount, options) {
32 return setISOWeekYear(date, getISOWeekYear(date, options) + amount, options);
33}
34
35// Fallback for modularized imports:
36export default addISOWeekYears;