Get date arrays before 1st day of the month in that week


@param year the year
@param month the month
@return date arrays before 1st day of the month in that week
353254
private Date[] getBeforeDays(int year, int month) {
        Calendar cal = Calendar.getInstance();
        cal.set(year, month, 1);
        int dayNum = getDayIndex(year, month, 1) - 1;
        Date[] date = new Date[dayNum];
        if (dayNum > 0)
            for (int i = 0; i < dayNum; i++) {
                cal.add(Calendar.DAY_OF_MONTH, -1);
                date[i] = cal.getTime();
            }

        return date;
    }
941945
public static Date getDate(int year, int month, int day) {
        GregorianCalendar d = new GregorianCalendar(year, month - 1, day);
        return d.getTime();
    }
1169259
@Override
    protected PlainDate getDate0(int year) {

        int month = this.getMonthValue();
        int lastDay = GregorianMath.getLengthOfMonth(year, month);
        int lastW = GregorianMath.getDayOfWeek(year, month, lastDay);
        int delta = (lastW - this.dayOfWeek);

        if (delta < 0) {
            delta += 7;
        }

        return PlainDate.of(year, month, lastDay - delta);

    }
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;
}
1294210
private int getDayIndex(int year, int month, int day) {
        Calendar cal = Calendar.getInstance();
        cal.set(year, month, day);
        return cal.get(Calendar.DAY_OF_WEEK);
    }
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];
	}
1253803
public int getDayOfYear() {

        switch (this.month) {
            case 1:
                return this.dayOfMonth;
            case 2:
                return 31 + this.dayOfMonth;
            default:
                return (
                    DAY_OF_YEAR_PER_MONTH[this.month - 2]
                    + this.dayOfMonth
                    + (GregorianMath.isLeapYear(this.year) ? 1 : 0));
        }

    }
1156293
function getDayOfMonth (date, month) {
  date = toStringDate(date)
  if (baseExports.isDate(date)) {
    return Math.floor((getDateTime(getWhatMonth(date, month, STRING_LAST)) - getDateTime(getWhatMonth(date, month, STRING_FIRST))) / DAY_TIME) + 1
  }
  return date
}
280812
public static function of(int $year, int $month) : YearMonth
    {
        Field\Year::check($year);
        Field\MonthOfYear::check($month);

        return new YearMonth($year, $month);
    }
1195173
public function daysInMonth($year, $month)
    {
        if ($year <= 0) {
            throw new InvalidArgumentException('Year ' . $year . ' is invalid for this calendar');
        } elseif ($month < 1 || $month > 13) {
            throw new InvalidArgumentException('Month ' . $month . ' is invalid for this calendar');
        } elseif ($month !== 13) {
            return 30;
        } elseif ($this->isLeapYear($year)) {
            return 6;
        } else {
            return 5;
        }
    }
1311936
private void getMonthlyRelativeDates(Calendar calendar, int frequency, List<Date> dates)
   {
      long startDate = calendar.getTimeInMillis();
      calendar.set(Calendar.DAY_OF_MONTH, 1);
      int dayNumber = NumberHelper.getInt(m_dayNumber);

      while (moreDates(calendar, dates))
      {
         if (dayNumber > 4)
         {
            setCalendarToLastRelativeDay(calendar);
         }
         else
         {
            setCalendarToOrdinalRelativeDay(calendar, dayNumber);
         }

         if (calendar.getTimeInMillis() > startDate)
         {
            dates.add(calendar.getTime());
            if (!moreDates(calendar, dates))
            {
               break;
            }
         }
         calendar.set(Calendar.DAY_OF_MONTH, 1);
         calendar.add(Calendar.MONTH, frequency);
      }
   }
516701
public static Long getMonth1stDay() {
		cal.setTimeInMillis(System.currentTimeMillis());
		cal.set(Calendar.DATE, 1);
		return cal.getTimeInMillis();
	}
1341541
function days_in_month($month = 0, $year = '') {
		if ($month < 1 || $month > 12) {
			$month = $this->mdate('m');
		}
		if (!is_numeric($year) || strlen($year) != 4) {
			$year = date('Y');
		}
		if ($month == 2) {
			if ($year % 400 == 0 || ($year % 4 == 0 && $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];
	}
429118
public static Date createDate(final int day, final int month, final int year) {
		Calendar cal = Calendar.getInstance();
		cal.clear();

		cal.set(Calendar.DAY_OF_MONTH, day);
		cal.set(Calendar.MONTH, month - 1);
		cal.set(Calendar.YEAR, year);

		return cal.getTime();
	}
145338
private Date[] getAfterDays(int year, int month) {
        Calendar cal = Calendar.getInstance();
        cal.set(Calendar.YEAR, year);
        cal.set(Calendar.MONTH, month);
        int dayNum = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
        cal.set(year, month, dayNum);
        int afterDayNum = 7 - getDayIndex(year, month, dayNum);
        Date[] date = new Date[afterDayNum];
        if (afterDayNum > 0)

            for (int i = 0; i < afterDayNum; i++) {
                cal.add(Calendar.DAY_OF_MONTH, 1);
                date[i] = cal.getTime();
            }

        return date;
    }
1225677
def monthdays2calendar(cls, year, month):
        
        weeks = []
        week = []
        for day in NepCal.itermonthdays2(year, month):
            week.append(day)
            if len(week) == 7:
                weeks.append(week)
                week = []
        if len(week) > 0:
            weeks.append(week)
        return weeks
1261414
public static Date getFirstDayOfMonth(Date date) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        int firstDay = calendar.getActualMinimum(Calendar.DAY_OF_MONTH);
        return org.apache.commons.lang.time.DateUtils.setDays(date, firstDay);
    }