getDaysOfMonth method
获得每个月的天数,闰月也就是2月通过年获取
- year 要获取的那一年的,用于计算
Implementation
int getDaysOfMonth(int month, {int? year}) {
assert(month <= 12 && month > 0);
switch (month) {
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
return 31;
case 4:
case 6:
case 9:
case 11:
return 30;
case 2:
return _getDaysOfFebruary(year: year);
default:
throw Exception("Unknown Exception, Month: $month");
}
}