daysInMonth property

int get daysInMonth

Returns the amount of days that are in the month of this.

Accounts for leap years.

Implementation

int get daysInMonth {
  assert(month >= 0 && month <= 11);
  switch (month) {
    case 0:
      return 31; // January
    case 1:
      return isLeapYear ? 29 : 28; // February
    case 2:
      return 31; // March
    case 3:
      return 30; // April
    case 4:
      return 31; // May
    case 5:
      return 30; // June
    case 6:
      return 31; // July
    case 7:
      return 31; // August
    case 8:
      return 30; // September
    case 9:
      return 31; // October
    case 10:
      return 30; // November
    case 11:
      return 31; // December
    default:
      throw StateError("'month' must be within [0;11]");
  }
}