index.js 715 B

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