I want to calculate the week number of a given date.
DateTime date = Convert.ToDateTime("31.12.2001"); DateTimeFormatInfo dfi = DateTimeFormatInfo.CurrentInfo; System.Globalization.Calendar cal = dfi.Calendar; int weekOfYear = cal.GetWeekOfYear(date, CalendarWeekRule.FirstFourDayWeek, dfi.FirstDayOfWeek);
In my DateTimeFormatInfo, the first day of the week is Monday. I want to use the four-day rule, which means that the week belongs to the year in which most of its days lie. December 31, 2001 - Monday, and then - on the 1st week of 2002. However, weekOfYear returns as 53.
Does anyone know what is wrong?
source share