Here you can find the source of addYear()
'use strict';/*w w w .java 2 s . c om*/ /** * Extends Javascript Date class by adding * utility methods for basic date incrementation */ /** * Increment year */ Date.prototype.addYear = function addYear () { this.setFullYear(this.getFullYear() + 1); };
Date.prototype.addYear = function(){
this.setFullYear(this.getFullYear() + 1);
};
Date.prototype.addYears = function (number) { var date = new Date(this); date.setFullYear(date.getFullYear() + number); return date; };
Date.prototype.addYears = function (numberOfYears) { var year = this.getFullYear(); year += parseInt(numberOfYears); this.setFullYear(year);
Date.prototype.addYears = function(value) { var month = this.getMonth(); this.setFullYear(this.getFullYear() + value); if (month < this.getMonth()) { this.setDate(0); return this; };
Date.prototype.addYears = function(y) { var m = this.getMonth(); this.setFullYear(this.getFullYear() + y); if (m < this.getMonth()) { this.setDate(0); };