Nodejs Utililty Methods Month Calculate

List of utility methods to do Month Calculate

Description

The list of methods to do Month Calculate are organized into topic(s).

Method

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':
...
monthOfYear()
Date.prototype.monthOfYear = function(){
  var months = ["January", "February", "March", 
                "April", "May", "June", "July", 
                "August", "September", "October", 
                "November", "December"];
  return months[this.getMonth()];
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);
...
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;
};
toMonthEnd()
Date.prototype.toMonthEnd = function () {
    var date = new Date(this);
    date.setMonth(date.getMonth() + 1);
    date.setDate(0);
    return date;
};
toMonthStart()
Date.prototype.toMonthStart = function () {
    var date = new Date(this);
    date.setDate(1);
    return date;
};