travel/admin/node_modules/date-fns/sub_years/index.js

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