November 2nd, 2018

Why does the MonthCalendar control show the wrong week numbers in Romania?

A customer liaison reported that the MonthCalendar control was showing incorrect week numbers when run on a Romanian system. They included screen shots of the calendar control running on a German system and a Romanian system for comparison:

◀︎ Januar 2016 ▶︎
Mo Di Mi Do Fr Sa So
53 28 29 30 31 1 2 3
1 4 5 6 7 8 9 10
2 11 12 13 14 15 16 17
3 18 19 20 21 22 23 24
4 25 26 27 28 29 30 31
 
◀︎ ianuarie 2016 ▶︎
L Ma Mi J V S D
1 28 29 30 31 1 2 3
2 4 5 6 7 8 9 10
3 11 12 13 14 15 16 17
4 18 19 20 21 22 23 24
5 25 26 27 28 29 30 31
Germany   Romania

January 1 falls on a Friday. The German calendar calls it week 53, but the Romanian calendar calls it week 1.

The customer liaison is making the implicit assumption that the German calendar is the correct one and the Romanian one is wrong. But that’s not what the Romanians think!

Under the Romanian calendar system, the first week of the year is the week that contains January 1. Under the German calendar system, the first week of the year is the week that contains at least four days from that year.

So both calendars are right, for their corresponding locales.

It turns out that this is the same customer liaison who asked the same question about the Romanian calendar nine months earlier. I was able to forward the answer to their previous question as a response to their current one. But it’s clear that they didn’t really understand the explanation, because they came back and asked, “Shouldn’t they be the same? The first week should be the same on the German system and on the Romanian system, right?”

No, that’s not right. Different locales have different rules for determining which week is the first week of the year, in the same way that different locales have different rules for determining which day is the first day of the week. Translating a calendar is more complicated than just doing a search-and-replace for the names of the days of the week and the names of the months. (And boy are they in for a surprise when they first encounter non-Gregorian calendars!)

Topics
Code

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

0 comments

Discussion are closed.