// 根据日期计算某个月有多少天 static int DaysOfMonth(int year, int month) { static const char sDays[2][12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; if (month < 1) { month += 12; year--; } else if (month > 12) { month -= 12; year++; } return sDays[(year % 100 != 0 && year % 4 == 0) || year % 400 == 0][month - 1]; }