// 根据日期计算星期几 static int CaculateWeekDay(int year, int month, int day) { int weekday; // 一月和二月被当作前一年的 if ((month == 1) || (month == 2)) { month += 12; year--; } weekday = (day + 2 * month + 3 * (month + 1) / 5 + year + year / 4 - year / 100 + year / 400) % 7 + 1; if (weekday == 7) weekday = 0; return weekday; }