Nodejs Month Calculate monthName(language)

Here you can find the source of monthName(language)

Method Source Code

Date.prototype.monthName = function(language) {
   var monthName = "";
   language = language || 'en';

   switch(language.toLowerCase()) 
   {/*w w w  .j  a v a 2s.  co  m*/
      case 'en':
         monthName = ['January','February','March','April','May','June','July', 'August','September','October','November','December'];
         break;
      case 'es':
         monthName = ['Enero','Febrero','Marzo','Abril','Mayo','Junio','Julio', 'Agosto','Setiembre','Octubre','Noviembre','Diciembre'];
         break;
   }
   
   return monthName[this.getMonth()];
};

Related

  1. 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;
    
  2. 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() 
    
  3. 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;
    
  4. month()
    Date.prototype.month = function()
      var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
      return months[this.getMonth()];
    
  5. monthAbbrev[ "Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec" ];
    Date.prototype.monthAbbrev = [ "Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec" ];
    Date.prototype.monthFull = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ];
    Date.prototype.weekAbbrev = [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
    Date.prototype.weekFull = [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
    Date.prototype.format = function(format)
      var output = format;
      output = output.replace("uHH",this.getUTCHours().toString().padLeft("0",2));
      output = output.replace("HH",this.getHours().toString().padLeft("0",2));
    ...
    
  6. monthOfYear()
    Date.prototype.monthOfYear = function(){
      var months = ["January", "February", "March", 
                    "April", "May", "June", "July", 
                    "August", "September", "October", 
                    "November", "December"];
      return months[this.getMonth()];
    
  7. previous_month()
    Date.prototype.previous_month = function() {
      var day = this.getDate();
      var month = this.getMonth() - 1;
      var year = this.getFullYear();
      if (month < 0) {
        month = 11;
        year--;
      return new Date(year, month, day);
    ...
    
  8. subMonths(value)
    Date.prototype.subMonths = function(value) {
      var date = this.getDate();
      this.setMonth(this.getMonth() - value);
      if (this.getDate() < date) {
        this.setDate(0);
      return this;
    };
    
  9. toMonthEnd()
    Date.prototype.toMonthEnd = function () {
        var date = new Date(this);
        date.setMonth(date.getMonth() + 1);
        date.setDate(0);
        return date;
    };