index.js 761 B

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