Nodejs Year Calculate increaseYear(num)

Here you can find the source of increaseYear(num)

Method Source Code

var weekdays = exports.weekdays = ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"];

Date.prototype.increaseYear = function(num) {
  this.setUTCFullYear(this.getUTCFullYear() + num);
}
Date.prototype.increaseMonth = function(num) {
  var str = this.getUTCFullYear()+"-"+(this.getUTCMonth()+num + 1)+"-"+
        this.getUTCDate()+"T"+this.getUTCHours()+":"+this.getUTCMinutes()+":"+
        this.getUTCSeconds()+"."+this.getUTCMilliseconds()+"Z";
  var date = new Date(str);
  this.setTime(date.getTime());/*from w  w  w.ja v a2 s . c  om*/
}
Date.prototype.increaseDay = function(num) {
  this.setUTCDate(this.getUTCDate() + num);
}
Date.prototype.increaseHour = function(num) {
  this.setUTCHours(this.getUTCHours() + num);
}

Date.prototype.increaseMinute = function(num) {
  this.setUTCMinutes(this.getUTCMinutes() + num);
}

Date.prototype.increaseSecond = function(num) {
  this.setUTCSeconds(this.getUTCSeconds() + num);
}

exports.ceilDate = function(date, delta){
  var ms = date.getTime();
  return new Date(Math.ceil(ms/delta)*delta);
}

exports.floorDate = function(date, delta){
  var ms = date.getTime();
  return new Date(Math.floor(ms/delta)*delta)
}

Related

  1. getYear()
    window = this;
    Date.prototype.getYear = function() {
      return new Date().getFullYear();
    };
    function Error(message, description) {
      const e = new Error(message);
      e.description = description;
      return e;
    
  2. isThisYear()
    Date.prototype.isThisYear = function() {
        return new Date().getYear() == this.getYear();
    };
    
  3. subYears(value)
    Date.prototype.subYears = function(value) {
      var month = this.getMonth();
      this.setFullYear(this.getFullYear() - value);
      if (month < this.getMonth()) {
        this.setDate(0);
      return this;
    };
    
  4. toYearEnd()
    Date.prototype.toYearEnd = function () {
        var date = new Date(this);
        date.setMonth(12);
        date.setDate(0);
        return date;
    };
    
  5. toYearStart()
    Date.prototype.toYearStart = function () {
        var date = new Date(this);
        date.setMonth(0);
        date.setDate(1);
        return date;
    };