使用基姆拉尔森计算公式
/// <summary> /// 计算某个日期为星期几 /// </summary> /// <param name="year">年</param> /// <param name="month">月</param> /// <param name="day">日</param> /// <returns>星期几</returns> public static string CaculateWeekDay(int year, int month, int day) { if (month == 1 || month == 2) { month += 12; year--; } int week = (day + 2 * month + 3 * (month + 1) / 5 + year + year / 4 - year / 100 + year / 400 + 1) % 7; string weekstr = ""; switch (week) { case 1: weekstr = "星期一"; break; case 2: weekstr = "星期二"; break; case 3: weekstr = "星期三"; break; case 4: weekstr = "星期四"; break; case 5: weekstr = "星期五"; break; case 6: weekstr = "星期六"; break; case 7: weekstr = "星期七"; break; } return weekstr; }