UNPKG

1.01 kBJavaScriptView Raw
1"use strict";
2exports.subBusinessDays = subBusinessDays;
3var _index = require("./addBusinessDays.js");
4
5/**
6 * @name subBusinessDays
7 * @category Day Helpers
8 * @summary Substract the specified number of business days (mon - fri) to the given date.
9 *
10 * @description
11 * Substract the specified number of business days (mon - fri) to the given date, ignoring weekends.
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 business days to be subtracted.
17 *
18 * @returns The new date with the business days subtracted
19 *
20 * @example
21 * // Substract 10 business days from 1 September 2014:
22 * const result = subBusinessDays(new Date(2014, 8, 1), 10)
23 * //=> Mon Aug 18 2014 00:00:00 (skipped weekend days)
24 */
25function subBusinessDays(date, amount) {
26 return (0, _index.addBusinessDays)(date, -amount);
27}