0

I am encountering an issue with the MonthCalendar Windows Form UI Control. With the ShowWeekNumbers property enabled, it shows week 1 of 2016 to be the week containing January 1st, which is on a Friday. This is not compliant with ISO-8601, which states that the first week of the year is the week that contains the year's first Thursday (first 4-day week).

The MonthCalendar control (SysMonthCal32) is part of the Common Control Library (comctl32.dll). It uses the MCS_WEEKNUMBERS style when displaying week numbers. On the Month Calendar Control Styles page of the MSDN site, it provides the following statement in the description of MSC_WEEKNUMBERS: "Week 1 is defined as the first week that contains at least four days." Unfortunately, that is contrary to what I'm experiencing with the control.

Here's a photo of the MonthCalendar control, showing the issue described above.

2 Answers2

1

I received a complaint about a not relevant no. of the working week which was displayed when running a Windows Form Application.

Specifically, the problem came from the fact that 1st and 2nd of January 2016 were recognised as being the next week, in this case, the first week of the 2016 see the application displaying the wrong no. of the week, meaning 2 instead of 1

In most calendars though, for countries like Austria, Deutschland, Switzerland the first week of 2016 is considered to be the week starting with 4th of January.

The fast solution to resolve this problem was to add on client PC, 2 in the iFirstweekofYear register instead of 0 (acces this register by running regedit->HKEY_CURRENT_USER->Control Panel->International->iFirstWeekOfYear)

Now, when I run again the application, the correct week of year is displayed: see the application displaying the correct no. of the week, meaning 1 instead of 2

I hope this helps.

0

The calculation for week numbering is determined by the operating system's user locale settings. It can not be influence by modifying the CurrentCulture and CurrentUICulture properties of the main execution thread. As stated by this Microsoft Support article:

This behavior occurs because the DateTimePicker control and the MonthCalendar control are Microsoft Windows common controls. Therefore, the operating system's user locale determines the user interface of these controls.

Unfortunately, the operating system's user locale settings can not be set during application runtime. To achieve ISO-8601 compliance, a custom control will be necessary. These culture-aware MonthCalendar and DateTimePicker controls on CodeProject should do nicely.