Files
Testing/html5-chat/nodeMulti/node_modules/date-fns/sub_years/index.js
sean 343b4a3f3f
Some checks are pending
deploy-testing / deploy (push) Waiting to run
Initial testing snapshot
2026-11-19 18:32:17 -05:00

25 lines
715 B
JavaScript

var addYears = require('../add_years/index.js')
/**
* @category Year Helpers
* @summary Subtract the specified number of years from the given date.
*
* @description
* Subtract the specified number of years from the given date.
*
* @param {Date|String|Number} date - the date to be changed
* @param {Number} amount - the amount of years to be subtracted
* @returns {Date} the new date with the years subtracted
*
* @example
* // Subtract 5 years from 1 September 2014:
* var result = subYears(new Date(2014, 8, 1), 5)
* //=> Tue Sep 01 2009 00:00:00
*/
function subYears (dirtyDate, dirtyAmount) {
var amount = Number(dirtyAmount)
return addYears(dirtyDate, -amount)
}
module.exports = subYears