Get a list of weeks for a year - with dates

前端 未结 5 1930
遇见更好的自我
遇见更好的自我 2020-12-03 06:02

I\'ve been racking my brains over this, but it\'s late on a Friday and I\'m going round in circles.

I need to create a list of working weeks for a drop down list, wi

5条回答
  •  暖寄归人
    2020-12-03 06:41

    Bear in mind, that week calculations are done differently in different cultures and there is not a bug if you see week number 53!

    using System.Globalization;
    
    CultureInfo cultInfo = CultureInfo.CurrentCulture;
    int weekNumNow = cultInfo.Calendar.GetWeekOfYear(DateTime.Now,
                         cultInfo.DateTimeFormat.CalendarWeekRule,
                             cultInfo.DateTimeFormat.FirstDayOfWeek); 
    

提交回复
热议问题