/// <summary> /// 计算指定日期的星期值。星期日为0,其他为对应的星期值 /// 默认返回:int类型的星期值 /// </summary> /// <param name="rq"> A System.DateTime</param> public static int CaculateWeekDay(DateTime rq) { int y = rq.Year; int m = rq.Month; int d = rq.Day; if (m == 1 || m == 2) { m += 12; y--; } int week = (d + 2 * m + 3 * (m + 1) / 5 + y + y / 4 - y / 100 + y / 400 + 1) % 7; return week; }
|
请发表评论