UNPKG

845 BJavaScriptView Raw
1"use strict";
2exports.addWeeks = addWeeks;
3var _index = require("./addDays.js");
4
5/**
6 * @name addWeeks
7 * @category Week Helpers
8 * @summary Add the specified number of weeks to the given date.
9 *
10 * @description
11 * Add the specified number of week to the given date.
12 *
13 * @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).
14 *
15 * @param date - The date to be changed
16 * @param amount - The amount of weeks to be added.
17 *
18 * @returns The new date with the weeks added
19 *
20 * @example
21 * // Add 4 weeks to 1 September 2014:
22 * const result = addWeeks(new Date(2014, 8, 1), 4)
23 * //=> Mon Sep 29 2014 00:00:00
24 */
25function addWeeks(date, amount) {
26 const days = amount * 7;
27 return (0, _index.addDays)(date, days);
28}