Nodejs Month Calculate monthAbbrev[ "Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec" ];

Here you can find the source of monthAbbrev[ "Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec" ];

Method Source Code

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"];

   //  www.j  a  v  a 2s .co  m
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));
   output = output.replace("umm",this.getUTCMinutes().toString().padLeft("0",2));
   output = output.replace("mm",this.getMinutes().toString().padLeft("0",2));
   output = output.replace("uss",this.getUTCSeconds().toString().padLeft("0",2));
   output = output.replace("ss",this.getSeconds().toString().padLeft("0",2));
   output = output.replace("uyyyy",this.getUTCFullYear().toString());
   output = output.replace("yyyy",this.getFullYear().toString());
   output = output.replace("uMM",(this.getUTCMonth()+1).toString().padLeft("0",2));
   output = output.replace("MM",(this.getMonth()+1).toString().padLeft("0",2));
   output = output.replace("uMMM",this.monthAbbrev[this.getUTCMonth()].toUpperCase());
   output = output.replace("MMM",this.monthAbbrev[this.getMonth()].toUpperCase());
   output = output.replace("udd",this.getUTCDate().toString().padLeft("0",2));
   output = output.replace("dd",this.getDate().toString().padLeft("0",2));
   output = output.replace("uK","Z");
   output = output.replace("K",this.getTimeZone());
   return output;
}

Date.prototype.getTimeZone = function()
{
   var output = "";
   var minutes = this.getTimezoneOffset();
   var hours = parseInt(minutes/60);
   minutes = minutes - (hours*60);
   if(hours > 0)
      output = "+";
   output = output + hours.toString().padLeft("0",2) + ":" + minutes.toString().padLeft("0",2);
   return output;
}

Related

  1. 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;
    
  2. 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;
    
  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());
        return tDate.getMonth() == pDate.getMonth() 
    
  4. 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;
    
  5. month()
    Date.prototype.month = function()
      var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
      return months[this.getMonth()];
    
  6. monthName(language)
    Date.prototype.monthName = function(language) {
      var monthName = "";
      language = language || 'en';
      switch(language.toLowerCase()) 
        case 'en':
          monthName = ['January','February','March','April','May','June','July', 'August','September','October','November','December'];
          break;
        case 'es':
    ...
    
  7. monthOfYear()
    Date.prototype.monthOfYear = function(){
      var months = ["January", "February", "March", 
                    "April", "May", "June", "July", 
                    "August", "September", "October", 
                    "November", "December"];
      return months[this.getMonth()];
    
  8. 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);
    ...
    
  9. 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;
    };