分类:
2006-08-22 11:37:35
按每周第一天是星期天来算
//当年第一天
DateTime fisrtDayOfYear = Convert.ToDateTime(DateTime.Now.Year.ToString() + "/" + "01/01");
Response.Write("当年的第一天:"+fisrtDayOfYear+"
");
//当年第一天是星期几
string firstWeekDayOfYear = fisrtDayOfYear.DayOfWeek.ToString();
Response.Write("当年第一天是星期几:"+firstWeekDayOfYear+"
");
int i;
switch (firstWeekDayOfYear)
{
case "Monday":
i = 6;
break;
case "Tuesday":
i = 5;
break;
case "Wednesday":
i = 4;
break;
case "Thursday":
i = 3;
break;
i = 2;
break;
case "Saturday":
i = 1;
break;
default:
i = 7;
break;
}
//当天为第几天
int currentDayOfYear = DateTime.Now.DayOfYear;
Response.Write("当天是当年的第几天:" + currentDayOfYear.ToString() + "
");
if (currentWeekOfYear <= 0)
currentWeekOfYear +=1;
else
currentWeekOfYear += 2;
Response.Write("当天是第" + currentWeekOfYear + "周
");
int currentWeekDay = (currentDayOfYear - i) % 7;
Response.Write("当天是星期" + (currentWeekDay-1));