/// <summary> /// 计算本周周一 /// </summary> /// <param name="date">该周中任意一天</param> /// <returns></returns> public static DateTime GetMondayDate(DateTime date) { int i = DayOfWeek.Monday - date.DayOfWeek; if (i == -1) i = 6; return date.AddDays(i); } /// <summary> /// 计算本周周日 /// </summary> /// <param name="date">该周中任意一天</param> /// <returns></returns> public static DateTime GetSundayDate(DateTime date) { int i = date.DayOfWeek - DayOfWeek.Sunday; if (i != 0) i = 7 - i; return date.AddDays(i); }
时间: 2024-10-08 23:41:46