Winforms DateTimePicker - Wrong week number

Viewed 174

When I set a Windows' Regional format to English (Sweden) (and same applies to e.g. Czech format) the last week of the year is 52 and new year start with week 1. Start of week is by default on Monday.

enter image description here

When I set a Windows' Regional format to English (Europe) (and same applies to e.g. Romanian format) the last week of the year is 53 and new year start with week 2. Start of week is by default on Sunday, but I have switched it to Monday (although the change has no effect on the calculation of the week number in this case).

enter image description here

I expect the week number would depend on what each country uses as beginning of week, but it just seems random? Sweden and Czechia use Monday as beginning of week and their calculation is the same. But Romania (and most of Europe) also use Monday as beginning of week, then why is the week number different?

I understand there is a difference in how Gregorian calendar and ISO8601, but according to this question if Windows is using only Gregorian, why does the calculation change?

Furthermore, what setting do I need to change, to affect this, other than changing the whole region?

1 Answers

The following is from What Are Week Numbers?.

Monday or Sunday First?

There are at least six different week numbering systems currently in use around the world.

The most common is the International Standard ISO 8601, where Monday is the first day of the week followed by Tuesday, Wednesday, Thursday, Friday, Saturday, and with Sunday as the seventh and final day. Using ISO 8601 can help diminish uncertainty and confusion when communicating internationally.

Not ISO 8601 in US & Canada

However, not every country follows this standard. Several countries, including the United States, Canada, Australia, and New Zealand, put Sunday at the start of the week on their calendars.

Which Years Have 53 Weeks?

The weeks of the year in a Gregorian calendar are numbered from week 1 to week 52 or 53, depending on several varying factors. Most years have 52 weeks, but if the year starts on a Thursday or is a leap year that starts on a Wednesday, that particular year will have 53 numbered weeks. These week numbers are commonly used in some European and Asian countries; but not so much in the United States.

Other issues

Some calendars just get it wrong, so checking your calculations against it, will cause confusion.

If you want to use the regional windows settings of each user, then your week numbers will not match, if you have user's in different regions, that use different week numbering schemes.

Alternative solution

The solution is to not use week numbers at all, but to specify weeks by their start- and end-dates.

Related