- private int WeekOfYear(string date)
- {
- DateTime curDay = Convert.ToDateTime(date);
- int firstdayofweek = Convert.ToInt32(Convert.ToDateTime(curDay.Year.ToString() + "-" + "1-1").DayOfWeek);
- int days = curDay.DayOfYear;
- int daysOutOneWeek = days - (7 - firstdayofweek);
- if (daysOutOneWeek <= 0)
- {
- return 1;
- }
- else
- {
- int weeks = daysOutOneWeek / 7;
- if (daysOutOneWeek % 7 != 0)
- weeks ++;
- return weeks + 1;
- }
- }
计算当前周是一年中的第几周的函数
最新推荐文章于 2021-04-28 19:41:05 发布