getDaysCountInMonth static method

int getDaysCountInMonth(
  1. int year,
  2. int month
)

Returns the number of days in the specified month and year.

Implementation

static int getDaysCountInMonth(int year, int month) {
  List<int> daysInMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];

  if (month == 2 && isLeapYear(year)) {
    return 29;
  }

  return daysInMonth[month - 1];
}