1、获取当前周的星期一
/// <summary>
/// 当前周的第一天(星期一)
/// </summary>
/// <param name="yearWeek">周数,格式:yyyywww</param>
/// <returns></returns>
private DateTime GetWeekStartTime(string yearWeek){
int year = int.Parse(yearWeek.Substring(0, 4));
//本年1月1日
DateTime firstOfYear = new DateTime(year, 1, 1);
//周数
int weekNum = int.Parse(yearWeek.Substring(4));
//本年1月1日与本周星期一相差的天数
int dayDiff = (firstOfYear.DayOfWeek == DayOfWeek.Sunday ? 7 : Convert.ToInt32(firstOfYear.DayOfWeek)) - 1;
//第一周的星期一
DateTime firstDayOfFirstWeek = firstOfYear.AddDays(-dayDiff);
//当前周的星期一
DateTime firstDayOfThisWeek = firstDayOfFirstWeek.AddDays((weekNum - 1) * 7);
return firstDayOfThisWeek;
}
2、获取当前周的星期天
/// <summary>
/// 当前周的最后一天(星期天)
/// </summary>
/// <param name="yearWeek