Week number calculation in date picker is wrong if a week starts with Sunday
The date-picker always displays the wrong week-number if you set the week to start with Sunday.
This behavior comes from the fact that the date-picker tries to find the week number based on the nearest Thursday to the first day of the respective week. It selects the following Thursday if the week starts with a Monday but the previous one if it starts with Sunday.
This however is the wrong approach as it should always select the Thursday of the current week (i.e. the following Thursday for this purpose). Otherwise the week number is always one off (or at least in 2009 and 2010).
The attached patch fixes this behavior and always selects the Thursday of the week of the given date. It thus provides the correct ISO 8601 week.
Note that you will still get in trouble in 2011, as the definition of the ISO 8601 week number as used in Europe (first week is the week which includes the Jan 4th) differs from the US week numbers (first week is the week which includes Jan 1st). So it might be a good idea to make the week-base configurable.
Updated by Holger Just over 13 years ago
Weeks in Redmine are always according ISO 8601. That means, the first week of the year is the one with the first Thursday of the year (or equivalently January 4). US-weeks on the other hand start at the week containing January 1.
Regarding the BugMash-10, I think, the patch is save, as it always selects the Thursday of the current week (rather than the nearest one). It should maybe made clear in the docs, that Redmine always uses ISO weeks.
See also #5329 for a related issue.