Nodejs Year Add addYear()

Here you can find the source of addYear()

Method Source Code

/*//from w w  w  .  j a va  2s.com
   node-schedule
   A cron-like and not-cron-like job scheduler for Node.
   
   This file adds convenience functions for performing incremental date math
   in the Gregorian calendar.
*/

Date.prototype.addYear = function(){
   this.setFullYear(this.getFullYear() + 1);
};

Related

  1. addYear()
    'use strict';
    Date.prototype.addYear = function addYear () {
      this.setFullYear(this.getFullYear() + 1);
    };
    
  2. addYears(number)
    Date.prototype.addYears = function (number) {
        var date = new Date(this);
        date.setFullYear(date.getFullYear() + number);
        return date;
    };
    
  3. addYears(numberOfYears)
    Date.prototype.addYears = function (numberOfYears) {
        var year = this.getFullYear();
        year += parseInt(numberOfYears);
        this.setFullYear(year);
    
  4. addYears(value)
    Date.prototype.addYears = function(value) {
      var month = this.getMonth();
      this.setFullYear(this.getFullYear() + value);
      if (month < this.getMonth()) {
        this.setDate(0);
      return this;
    };