Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
28 lines
1010 B
Plaintext
28 lines
1010 B
Plaintext
"use strict";
|
|
exports.subBusinessDays = subBusinessDays;
|
|
var _index = require("./addBusinessDays.js");
|
|
|
|
/**
|
|
* @name subBusinessDays
|
|
* @category Day Helpers
|
|
* @summary Substract the specified number of business days (mon - fri) to the given date.
|
|
*
|
|
* @description
|
|
* Substract the specified number of business days (mon - fri) to the given date, ignoring weekends.
|
|
*
|
|
* @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).
|
|
*
|
|
* @param date - The date to be changed
|
|
* @param amount - The amount of business days to be subtracted.
|
|
*
|
|
* @returns The new date with the business days subtracted
|
|
*
|
|
* @example
|
|
* // Substract 10 business days from 1 September 2014:
|
|
* const result = subBusinessDays(new Date(2014, 8, 1), 10)
|
|
* //=> Mon Aug 18 2014 00:00:00 (skipped weekend days)
|
|
*/
|
|
function subBusinessDays(date, amount) {
|
|
return (0, _index.addBusinessDays)(date, -amount);
|
|
}
|