获取周数,但周应从周一开始,而不是周日

时间:2013-02-26 07:55:36

标签: c# datetime

我想获得整整一周的周数,但本周应该从周一而不是周日开始。我的代码的输出是,是的,我得到全年的周数,但它从周日开始。

 DateTime nicole = new DateTime();

 for (int i = 1; i <= 366; i++)
 {  
       System.Globalization.CultureInfo ci = System.Threading.Thread.CurrentThread.CurrentCulture;

       Int32 weekNo = ci.Calendar.GetWeekOfYear(
              new DateTime(nicole.Year,1, 1).AddDays(i-1),
              ci.DateTimeFormat.CalendarWeekRule,
              ci.DateTimeFormat.FirstDayOfWeek
       );
       datarow["Week_In_Year"] = "Week" + " " + weekNo;
 }

0 个答案:

没有答案
相关问题