UNPKG

904 BJavaScriptView Raw
1"use strict";
2exports.subQuarters = subQuarters;
3var _index = require("./addQuarters.js");
4
5/**
6 * @name subQuarters
7 * @category Quarter Helpers
8 * @summary Subtract the specified number of year quarters from the given date.
9 *
10 * @description
11 * Subtract the specified number of year quarters from 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 quarters to be subtracted.
17 *
18 * @returns The new date with the quarters subtracted
19 *
20 * @example
21 * // Subtract 3 quarters from 1 September 2014:
22 * const result = subQuarters(new Date(2014, 8, 1), 3)
23 * //=> Sun Dec 01 2013 00:00:00
24 */
25function subQuarters(date, amount) {
26 return (0, _index.addQuarters)(date, -amount);
27}