index.js 959 B

123456789101112131415161718192021222324252627
  1. var getISOYear = require('../get_iso_year/index.js')
  2. var setISOYear = require('../set_iso_year/index.js')
  3. /**
  4. * @category ISO Week-Numbering Year Helpers
  5. * @summary Add the specified number of ISO week-numbering years to the given date.
  6. *
  7. * @description
  8. * Add the specified number of ISO week-numbering years to the given date.
  9. *
  10. * ISO week-numbering year: http://en.wikipedia.org/wiki/ISO_week_date
  11. *
  12. * @param {Date|String|Number} date - the date to be changed
  13. * @param {Number} amount - the amount of ISO week-numbering years to be added
  14. * @returns {Date} the new date with the ISO week-numbering years added
  15. *
  16. * @example
  17. * // Add 5 ISO week-numbering years to 2 July 2010:
  18. * var result = addISOYears(new Date(2010, 6, 2), 5)
  19. * //=> Fri Jun 26 2015 00:00:00
  20. */
  21. function addISOYears (dirtyDate, dirtyAmount) {
  22. var amount = Number(dirtyAmount)
  23. return setISOYear(dirtyDate, getISOYear(dirtyDate) + amount)
  24. }
  25. module.exports = addISOYears