Question

Is it possible to get firstWeekday depending on location. For instance, in USA it should say Sunday. In Russia it should say Monday.

Edit: [[NSCalendar currentCalendar] firstWeekday] always says 1, but for Russia it should say 2

Was it helpful?

Solution

Your assumption is wrong. The calendar shouldn't return 1 in USA and 2 in Russia.

First of all, the device never knows in which country it is located. It takes everything from the Regional Settings in the Device Settings. The regional settings are then accessible through NSLocale, e.g. en-US means that USA English settings should be used, including the first week day.

In general, you should just use [NSLocale defaultLocale], which is implicitly set on NSCalendar, NSDateFormatter and similar classes. If you want to simulate the behavior with different language/regional settings, just change them in Device Settings.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top