Also affects calendar. I found that problem in our redmine installation and it turns out it's related to the start of the week. Problem is that week 1 of 2009 starts on december 2008,
If you go to calendar for January 2009, the first week is week 52 of 2008, when it should be week 1 of 2009. This doesn't happen if week starts on Monday.
For any week number calculation you should use Monday as first day of week. I would submit a patch, but I don't see any quick way to fix it, I just hacked it to force monday as first day of week, regardless which language you are using.
>> d-=1
=> Thu, 01 Jan 2009
>> [d.cweek,d.year,d.to_s]
=> [1, 2009, "2009-01-01"]
>> d-=1
=> Wed, 31 Dec 2008
>> [d.cweek,d.year,d.to_s]
=> [1, 2008, "2008-12-31"]
>> d-=1
=> Tue, 30 Dec 2008
>> [d.cweek,d.year,d.to_s]
=> [1, 2008, "2008-12-30"]
>> d-=1
=> Mon, 29 Dec 2008
>> [d.cweek,d.year,d.to_s]
=> [1, 2008, "2008-12-29"]
>> d-=1
=> Sun, 28 Dec 2008
>> [d.cweek,d.year,d.to_s]
=> [52, 2008, "2008-12-28"]
More info about week counting at http://en.wikipedia.org/wiki/ISO_week_date
Quoting:
Mutually equivalent definitions for week 01 are:
- the week with the year's first Thursday in it (the ISO 8601 definition)
- the week starting with the Monday which is nearest in time to 1 January
- the week with the year's first working day in it (if Saturdays, Sundays, and 1 January are not working days)
- the week with January 4 in it
- the first week with the majority (four or more) of its days in the starting year
- the week starting with the Monday in the period 29 December - 4 January
- the week with the Thursday in the period 1 - 7 January
- If 1 January is on a Monday, Tuesday, Wednesday or Thursday, it is in week 01. If 1 January is on a Friday, Saturday or Sunday, it is in week 52 or 53 of the previous year.
I hope this helps fixing the problem. Also, fixing #2884 would allow a quick workaround