subBusinessDays.js 1010 B

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