0

In .NET control MonthCalendar you can enable display of week number. Does anybody know which rule applies for these number?

enter image description here

.NET provides several rules for calculating the week number, see Calendar.GetWeekOfYear - and the most important one according ISO-8601 is even missing. I did not find any CalendarWeekRule property, so it seems to be fixed, but which one?

Wernfried Domscheit
  • 54,457
  • 9
  • 76
  • 110
  • I think they just wrap the windows common control, which is documented [here](http://msdn.microsoft.com/en-us/library/windows/desktop/bb760919(v=vs.85).aspx): "Week 1 is defined as the first week that contains at least four days" – Damien_The_Unbeliever Jan 20 '15 at 08:48
  • Apparently not: *The month calendar control displays week numbers (1-52) to the left of each row of days.* This is in contradictory when you go to December 2009 where the last week is 53! – Wernfried Domscheit Jan 20 '15 at 09:04
  • well, you can choose not to believe me but if you go and look at the [source](http://referencesource.microsoft.com/#System.Windows.Forms/winforms/Managed/System/WinForms/MonthCalendar.cs,703e7d03747f00aa) for the month control, you can see it working with a lot of native code and the `showWeekNumbers` property is used to decide whether to apply a value called `MCS_WEEKNUMBERS` to a style property, which is exactly the documentation I linked to. When using "first week with at least four days", it's actually quite common to end up with a week 53, so it may be wrong documentation – Damien_The_Unbeliever Jan 20 '15 at 09:14
  • @Damien_The_Unbeliever, yes looks more to be an error in the documentaion. – Wernfried Domscheit Jan 20 '15 at 09:38
  • btw, "first week with at least four days" is exactly the definition according ISO-8601 – Wernfried Domscheit Jan 20 '15 at 12:49

0 Answers0