C# 获取输入日期为一年中的第几周

 1 /// <summary>
 2 /// 获取指定日期,在为一年中为第几周
 3 /// </summary>
 4 /// <param name="dtWeek">指定时间</param>
 5 /// <reutrn>返回第几周</reutrn>
 6 private static int GetWeekOfYear(DateTime dtWeek)
 7 {
 8   System.Globalization.GregorianCalendar gc = new System.Globalization.GregorianCalendar();
 9   int weekOfYear = gc.GetWeekOfYear(dtWeek,System.Globalization.CalendarWeekRule.FirstDay, DayOfWeek.Monday);
10   return weekOfYear;
11 }

 

posted @ 2019-05-22 17:53  forack  阅读(1201)  评论(0编辑  收藏  举报