Why does pseudocode below return 2 as Week number? Shouldn’t it be 1?
string x = cal.GetWeekOfYear(02.01.2012 as datetime, cultureInfo.currentculture.DateTimeFormat.CalendarWeekRule, CultureInfo.CurrentCulture.DateTimeFormat.FirstDayOfWeek).toString();
You say the CalendarWeekRule of your current culture is
FirstDay, which is defined as (emphasis mine):You also say the first day of your week is Monday.
January 1st, 2012 was a Sunday, and the first week starts with that day. Since the first day of your week is Monday, the first week ends before the following Monday, i.e. on Sunday itself.
Therefore, January 2nd, 2012 is indeed the first day of week 2 under your culture’s settings.