Hi,
I'm trying to implement a dynamic calendar where the first day of the week will be based on the locale, unfortunately, it seems NSLocale doesn't conform with the regions in the world, only works for US, for example:
NSCalendar *calendar = [NSCalendar currentCalendar];
NSLocale *locale = [NSLocale localeWithLocaleIdentifier:@"pt_BR"];
[calendar setLocale:locale];
NSLog(@"firstDayOfWeek: %@", [calendar firstWeekday]); // Returns 2, which is Monday but in Brazil the first day of week is Sunday, it should return 1
NSCalendar *calendar = [NSCalendar currentCalendar];
NSLocale *locale = [NSLocale localeWithLocaleIdentifier:@"en_US"];
[calendar setLocale:locale];
NSLog(@"firstDayOfWeek: %@", [calendar firstWeekday]); // Returns 1, which is correct for United States
Does anybody know which standard the NSLocale follows to return on the first day of the week?
I mean, does it follows any ISO standard?
I’ve no idea.
Apple usually gets this sort of info from CLDR. It seems that CLDR does include first-day-of-the-week info, namely the firstDay element discussed here. You should look up the Brazil tables to see what that’s set to. That might also tell you where the value comes from. And if you think that’s wrong, CLDR has a process for requesting a fix. And it CLDR changes, those changes usually flow through to Apple platforms in the next major OS release.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"