获取本周指定周几的日期
/// <summary> /// 获取本周指定周几的日期 /// </summary> /// <returns></returns> public string GetThisWeekMonday(System.DayOfWeek dw) { DateTime firstDate; DateTime date; dtpBeginTime.Value = firstDate = date = Client.SystemDate; switch (date.DayOfWeek) { case System.DayOfWeek.Monday: firstDate = date; break; case System.DayOfWeek.Tuesday: firstDate = date.AddDays(-1); break; case System.DayOfWeek.Wednesday: firstDate = date.AddDays(-2); break; case System.DayOfWeek.Thursday: firstDate = date.AddDays(-3); break; case System.DayOfWeek.Friday: firstDate = date.AddDays(-4); break; case System.DayOfWeek.Saturday: firstDate = date.AddDays(-5); break; case System.DayOfWeek.Sunday: firstDate = date.AddDays(-6); break; } DateTime dt = firstDate; switch (dw) { case System.DayOfWeek.Tuesday: dt = dt.AddDays(1); break; case System.DayOfWeek.Wednesday: dt = dt.AddDays(2); break; case System.DayOfWeek.Thursday: dt = dt.AddDays(3); break; case System.DayOfWeek.Friday: dt = dt.AddDays(4); break; case System.DayOfWeek.Saturday: dt = dt.AddDays(5); break; case System.DayOfWeek.Sunday: dt = dt.AddDays(6); break; } return dt.ToString("D"); }
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步