Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 

27 linhas
1.1 KiB

  1. import toInteger from '../_lib/toInteger/index.js';
  2. import addBusinessDays from '../addBusinessDays/index.js';
  3. import requiredArgs from '../_lib/requiredArgs/index.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. * @param {Date|Number} date - the date to be changed
  13. * @param {Number} amount - the amount of business days to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
  14. * @returns {Date} the new date with the business days subtracted
  15. * @throws {TypeError} 2 arguments required
  16. *
  17. * @example
  18. * // Substract 10 business days from 1 September 2014:
  19. * var result = subBusinessDays(new Date(2014, 8, 1), 10)
  20. * //=> Mon Aug 18 2014 00:00:00 (skipped weekend days)
  21. */
  22. export default function subBusinessDays(dirtyDate, dirtyAmount) {
  23. requiredArgs(2, arguments);
  24. var amount = toInteger(dirtyAmount);
  25. return addBusinessDays(dirtyDate, -amount);
  26. }