index.js 705 B

123456789101112131415161718192021222324
  1. var addDays = require('../add_days/index.js')
  2. /**
  3. * @category Day Helpers
  4. * @summary Subtract the specified number of days from the given date.
  5. *
  6. * @description
  7. * Subtract the specified number of days from the given date.
  8. *
  9. * @param {Date|String|Number} date - the date to be changed
  10. * @param {Number} amount - the amount of days to be subtracted
  11. * @returns {Date} the new date with the days subtracted
  12. *
  13. * @example
  14. * // Subtract 10 days from 1 September 2014:
  15. * var result = subDays(new Date(2014, 8, 1), 10)
  16. * //=> Fri Aug 22 2014 00:00:00
  17. */
  18. function subDays (dirtyDate, dirtyAmount) {
  19. var amount = Number(dirtyAmount)
  20. return addDays(dirtyDate, -amount)
  21. }
  22. module.exports = subDays