NSCalendar calculations for Russian locale are wrong

Originator:kanoshkin
Number:rdar://6002825 Date Originated:12-Jun-2008
Status:Open Resolved:
Product:iPhone SDK Product Version:
Classification: Reproducible:
 
Summary
Calculating the first weekday of a date's week for the Russian locale yields the next week.

Steps to Reproduce
The following code works correctly for the US locale, the weekStart variable pointing to the last Sunday. However, if the Russian locale is set in Settings applications, General>International>Region Format, the weekStart variable points to the next Sunday.
// Get today's week
NSDateComponents *thisWeek = [[NSCalendar currentCalendar] components: NSEraCalendarUnit | NSYearCalendarUnit | NSMonthCalendarUnit | NSWeekCalendarUnit fromDate: [NSDate date]];
// Get the first day of this week
NSUInteger firstDay = [[NSCalendar currentCalendar] maximumRangeOfUnit: NSWeekdayCalendarUnit].location;
// Get the start of the first day of this week as NSDate in the current time zone
[thisWeek setWeekday: firstDay];
NSDate *weekStart = [[NSCalendar currentCalendar] dateFromComponents: thisWeek];

Expected Results
Weeks traditionally start on Monday in Russia, so the correct result would be the last Monday. Given that Russia uses the same Gregorian calendar as the United States, the last Sunday is also correct.

Notes
The following results were observed on June 12, 2008.
Examining thisWeek variable shows that it contains the same components for both locales:
Era=1 Year=2008 Month=6 Week=24 Weekday=1
However, the dates calculated by NSCalendar are different:
Russian locale: (2008-06-15 00:00:00 +0400 - 2008-06-22 00:00:00 +0400)
US locale: (2008-06-08 00:00:00 +0400 - 2008-06-15 00:00:00 +0400)

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!