daysInMonth static method

  1. @useResult
int daysInMonth(
  1. int year,
  2. int month
)

Computes the number of days in the given month taking leap years into account.

Dates.daysInMonth(2019, 2); // 28
Dates.daysInMonth(2020, 2); // 29

Implementation

@useResult static int daysInMonth(int year, int month) => (leapYear(year) ? leapYearMonths : nonLeapYearMonths)[month - 1];