getDayCounts static method
获取一个月有多少天
Implementation
static int getDayCounts(int month) {
int year = DateTime.now().year;
int end = switch (month) {
1 => 31,
2 => (year % 4 == 0) && (year % 100 != 0) || (year % 400 == 0) ? 29 : 28,
3 => 31,
4 => 30,
5 => 31,
6 => 30,
7 => 31,
8 => 31,
9 => 30,
10 => 31,
11 => 30,
12 => 31,
_ => 0,
};
return end;
}