Return starting weekday (0-6 ~ Mon-Sun) and number of days (28-31) for
year, month.

@param {Number} year
@param {Number} month
@throws {IllegalMonthError} If the provided month is invalid.
@api public
519958
function monthrange(year, month) {
      if(month < 1 || month > 12) {
        throw new IllegalMonthError();
      }

      var day1 = weekday(year, month, 1);
      var ndays = _DAYS_IN_MONTH[month] + (month === 2 && isleap(year));

      return [day1, ndays];
    }
601476
function(offset) {
			var month = this.getOffsetMonth(offset)
			  , year = this.getOffsetYear(offset)

			// checks to see if february is a leap year otherwise return the respective # of days
			return (month == 1 && !(year & 3) && (year % 1e2 || !(year % 4e2))) ? 29 : this.daysInMonth[month]
		}
212197
function(date) {
        var start = this.findMonthStart(date);
        var nextMonth = this.add(start, this.MONTH, 1);
        var end = this.subtract(nextMonth, this.DAY, 1);
        return end;
    }
497934
private int parseMonth(String month) {
    for (int i = 0; i < months.length; i++)
      if (months[i].startsWith(month))
        return i;
    return -1;
  }
143508
private long monthStart(int year, int month) {
        // Normalize year/month in case month is outside the normal bounds, which may occur
        // in the case of an add operation
        int realYear = year + month / 12;
        int realMonth = month % 12;
        long ms = 0;
        if (cType == CalculationType.ISLAMIC_CIVIL
                || cType == CalculationType.ISLAMIC_TBLA
                || (cType == CalculationType.ISLAMIC_UMALQURA && year < UMALQURA_YEAR_START )) {
            ms = (long)Math.ceil(29.5*realMonth)
                    + (realYear-1)*354 + (long)Math.floor((3+11*realYear)/30.0);
        } else if(cType == CalculationType.ISLAMIC) {
            ms = trueMonthStart(12*(realYear-1) + realMonth);
        } else if(cType == CalculationType.ISLAMIC_UMALQURA) {
            ms = yearStart(year);
            for(int i=0; i< month; i++) {
                ms+= handleGetMonthLength(year, i);
            }
        }

        return ms;
    }
1369263
public static function daysInMonth(int $month, int $year = null)
    {
        // Redefine vars
        $year   = ! empty($year) ? $year : (int) date('Y');

        if ($month < 1 or $month > 12) {
            return false;
        } elseif ($month == 2) {
            if ($year % 400 == 0 or ($year % 4 == 0 and $year % 100 != 0)) {
                return 29;
            }
        }

        $days_in_month = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

        return $days_in_month[$month-1];
    }
742775
function mstart($month,$day,$year)

	{

		list( $jyear, $jmonth, $jday ) = $this->gregorian_to_jalali($year, $month, $day);

		list( $year, $month, $day ) = $this->jalali_to_gregorian($jyear, $jmonth, "1");

		$timestamp=mktime(0,0,0,$month,$day,$year);

		return date("w",$timestamp);

	}
512058
def daysInMonth(self, month, year):
        
        result = None
        debug and log.debug('daysInMonth(%s, %s)', month, year)
        if month > 0 and month <= 12:
            result = self._DaysInMonthList[month - 1]

            if month == 2:
                if year in self._leapYears:
                    result += 1
                else:
                    if calendar.isleap(year):
                        self._leapYears.append(year)
                        result += 1

        return result
764748
private void calculateMonth()
  {
    _dayOfMonth = _dayOfYear;

    for (_month = 0; _month < 12; _month++) {
      if (_month == 1 && _isLeapYear) {
        if (_dayOfMonth < 29)
          return;
        else
          _dayOfMonth -= 29;
      }
      else if (_dayOfMonth < DAYS_IN_MONTH[(int) _month])
        return;
      else
        _dayOfMonth -= DAYS_IN_MONTH[(int) _month];
    }
  }
877030
function getMonthDays(year, month) {
  let NUM = 30;
  if ([1, 3, 5, 7, 8, 10, 12].indexOf(month) !== -1) {
    NUM = 31;
  }
  if (month === 2) {
    NUM = isLeapYear(year) ? 29 : 28;
  }
  return NUM;
}
632596
public static function days_in_month($month, $year = null)
	{
		$year  = ! empty($year) ? (int) $year : (int) date('Y');
		$month = (int) $month;

		if ($month < 1 or $month > 12)
		{
			throw new \UnexpectedValueException('Invalid input for month given.');
		}
		elseif ($month == 2)
		{
			if ($year % 400 == 0 or ($year % 4 == 0 and $year % 100 != 0))
			{
				return 29;
			}
		}

		$days_in_month = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
		return $days_in_month[$month-1];
	}
665459
function(days) {

    days += DISTANCE;

    var months = days2yearsInMonths(days);
    var currentYear = getNewYearInDays(months);
    var nextYear;

    if(currentYear > days) {
      nextYear = currentYear;
      months = days2yearsInMonths(days - 7);
      currentYear = getNewYearInDays(months);
    }
    days -= currentYear;
    var year = months2year(months);
    var leap = isLeap(year);
    nextYear = nextYear || getNextYearInDays(months, leap);
    var mode = getYearMode(currentYear, nextYear, leap);

    if(days > 87) {
      days -= mode;
    } else if(days > 58 && mode == 1) {
      days -= 0.5;
    }

    if(days > 176) days -= leap;

    var month = Math.floor(days / 29.5);
    var date = Math.floor(days % 29.5);

    // change value back from zero-based
    year++;
    date++;

    return {
      year: year,
      month: month,
      date: date
    }
  }
806500
function monthCalendar(date) {
    var start = date.clone().startOf("month").startOf("week").startOf("day");
    var end = date.clone().endOf("month").endOf("week").startOf("day");
    var result = [];
    var current = start.weekday(0).subtract(1, "d");
    while (true) {
        current = current.clone().add(1, "d");
        result.push(current);
        if (areDatesEqual(current, end)) {
            break;
        }
    }
    return result;
}
90020
function getMonth(moment, service, dt) {
	
	const dateService = new service(moment, dt);
  
  return {
    longName: dateService.monthLong(),
    shortName: dateService.monthShort(),
    daysCount: dateService.daysCount(),
    startDayOfMonth: dateService.startDayOfMonth(),
  };
}
919677
public static function gregorianToJd($month, $day, $year)
    {
        if ($year == 0) {
            return 0;
        } else {
            return self::$gregorian_calendar->ymdToJd($year, $month, $day);
        }
    }
208017
function(year) {
    var self = this;
    var month = 6;
    var midsummerDay;

    self.range(20, 26).forEach(function(day) {
      if (!midsummerDay) {
        var date = self.createDate(year, month, day);
        var dayOfWeek = self.getDayOfWeek(date);

        if (dayOfWeek === self.SATURDAY) {
          midsummerDay = date;
        }
      }
    });

    return midsummerDay;
  }
42659
public static function numberOfDaysInMonth($month = 0, $year = 0)
    {
        if ($month < 1 or $month > 12) {
            return 0;
        }

        if (!is_numeric($year) or strlen($year) != 4) {
            $year = date('Y');
        }

        if ($month == 2) {
            if ($year % 400 == 0 or ($year % 4 == 0 and $year % 100 != 0)) {
                return 29;
            }
        }

        $days_in_month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];

        return $days_in_month[$month - 1];
    }