Jordan Smith
Jordan Smith

Reputation: 10378

Objective C - Get localised Weekend and Weekday names?

What I'd like is a way of getting separated weekday and weekend names in iOS (localised). I understand that there is NSDateformatter's "weekdaySymbols" method, but this doesn't distinguish between weekend and weekday.

The problem I am facing is that different localisations may place their "weekdaySymbols" differently, starting on Monday instead of Sunday for example, so I can't guarantee what index of the array weekend days will appear.

How can I do what I'd like?

Upvotes: 4

Views: 557

Answers (1)

rmaddy
rmaddy

Reputation: 318944

The index for weekdaySymbols is always the same. 0 for Sunday, 1 for Monday, etc. through 6 for Saturday. This is the same regardless of the user's locale.

All locales consider Saturday and Sunday to be the weekend. Though some locales treat Sunday as the 1st day of the week while others treat it as the last day. This can be determined from the NSCalendar firstWeekday method.

Upvotes: 2

Related Questions