index.js 748 B

12345678910111213141516171819202122232425
  1. var addMonths = require('../add_months/index.js')
  2. /**
  3. * @category Quarter Helpers
  4. * @summary Add the specified number of year quarters to the given date.
  5. *
  6. * @description
  7. * Add the specified number of year quarters to 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 added
  11. * @returns {Date} the new date with the quarters added
  12. *
  13. * @example
  14. * // Add 1 quarter to 1 September 2014:
  15. * var result = addQuarters(new Date(2014, 8, 1), 1)
  16. * //=> Mon Dec 01 2014 00:00:00
  17. */
  18. function addQuarters (dirtyDate, dirtyAmount) {
  19. var amount = Number(dirtyAmount)
  20. var months = amount * 3
  21. return addMonths(dirtyDate, months)
  22. }
  23. module.exports = addQuarters