Nodejs Month Calculate incrementMonth( iIncrementValue )

Here you can find the source of incrementMonth( iIncrementValue )

Method Source Code

var aMonths = [ 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' ]
var aDays = [ 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' ]

Date.prototype.incrementMonth = function ( iIncrementValue )
{
   this.setMonth(/*from w w w  . j a va 2 s .  co  m*/
      this.getMonth() + iIncrementValue
   )
}

Date.prototype.toDayString = function ()
{
   return aDays[ this.getDay() ]
}

Date.prototype.toMonthString = function ()
{
   return aMonths[ this.getMonth() ]
}

Date.prototype.toInputString = function ()
{
   var sDay = ( "0" + this.getDate() ).slice( -2 )
   var sMonth = ( "0" + ( this.getMonth() + 1 ) ).slice( -2 )
   return this.getFullYear() + '-' + sMonth + '-' + sDay
}

Date.prototype.resetDateToToday = function ()
{
   var oToday = new Date()
   this.setDate( oToday.getDate() )
   this.setMonth( oToday.getMonth() )
   this.setFullYear( oToday.getFullYear() )
}

Date.prototype.isEquals = function ( iDate, iMonth, iYear )
{
    if ( this.getDate() == iDate && this.getMonth() == iMonth && this.getFullYear() == iYear ) {
        return true
    }
    return false
}

module.exports = Date

Related

  1. getMonth2()
    Date.prototype.getMonth2 = function () {
       var month = this.getMonth() + 1;
       return (month < 10 ? '0' : '') + month;
    };
    
  2. getMonthEnd()
    Date.prototype.getMonthEnd = function () {
      return new Date(this.getFullYear(), this.getMonth() + 1, 0);
    };
    
  3. getMonthStart()
    Date.prototype.getMonthStart = function () {
      return new Date(this.getFullYear(), this.getMonth(), 1);
    };
    
  4. getShortMonth()
    Date.prototype.getShortMonth = function () {
       return ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"][this.getMonth()];
    };
    
  5. getShortMonthName()
    Date.prototype.getShortMonthName = function () {
      var monthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
        "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
      ];
      return monthNames[this.getMonth()];
    };
    
  6. isAfterMonth(d)
    Date.prototype.isAfterMonth = function (d) {
        var tDate = new Date(this.getFullYear(), this.getMonth(), this.getDate());
        var pDate = new Date(d.getFullYear(), d.getMonth(), d.getDate());
        if(tDate.getFullYear() < pDate.getFullYear()) return false;
        if(tDate.getMonth() < pDate.getMonth()) return false;
        return true;
    
  7. isBeforeMonth(d)
    Date.prototype.isBeforeMonth = function (d) {
        var tDate = new Date(this.getFullYear(), this.getMonth(), this.getDate());
        var pDate = new Date(d.getFullYear(), d.getMonth(), d.getDate());
        if(tDate.getFullYear() > pDate.getFullYear()) return false;
        if(tDate.getMonth() > pDate.getMonth()) return false;
        return true;
    
  8. isSameMonth(d)
    Date.prototype.isSameMonth = function (d) {
        var tDate = new Date(this.getFullYear(), this.getMonth(), this.getDate());
        var pDate = new Date(d.getFullYear(), d.getMonth(), d.getDate());
        return tDate.getMonth() == pDate.getMonth() 
    
  9. isSameMonth(d)
    Date.prototype.isSameMonth = function(d){
        var tDate = new Date(this.getFullYear(), this.getMonth(), this.getDate());
        var pDate = new Date(d.getFullYear(), d.getMonth(), d.getDate());
        if(tDate.getFullYear() != pDate.getFullYear()) return false;
        if(tDate.getMonth() != pDate.getMonth()) return false;
        return true;