lastDayInMonth method
当月最后一天
firstDay
- 每月起算日期,assert(firstDay > 0 && firstDay < 29)
Implementation
DateTime lastDayInMonth([int firstDay = 1]) {
assert(firstDay > 0 && firstDay < 29);
if (firstDay <= day) {
return DateTime(
year,
month + 1,
min(firstDay - 1,
DateTime(year, month + 2).subtract(Duration(days: 1)).day));
} else {
return DateTime(
year,
month,
min(firstDay - 1,
DateTime(year, month + 1).subtract(Duration(days: 1)).day));
}
}