/// <summary>根据日期,获得星期几</summary>
/// <param name="y">年</param>
/// <param name="m">月</param>
/// <param name="d">日</param>
/// <returns>星期几</returns>
public static string getWeekDay(DateTime date)
{
string weekDay = "";
int m = date.Month;
int y = date.Year;
int d = date.Day;
if (m == 1) m = 13;
if (m == 2) m = 14;
int week = (d + 2 * m + 3 * (m + 1) / 5 + y + y / 4 - y / 100 + y / 400) % 7 + 1;
switch (week)
{
case 1:
weekDay = " 星期一";
break;
case 2:
weekDay = " 星期二";
break;
case 3:
weekDay = " 星期三";
break;
case 4:
weekDay = " 星期四";
break;
case 5:
weekDay = " 星期五";
break;
case 6:
weekDay = " 星期六";
break;
case 7:
weekDay = " 星期日";
break;
}
return weekDay;
}
根据日期查询星期
最新推荐文章于 2020-09-09 21:48:08 发布