Quick idea off the top of my head:

Ask an NSDateFormatter for its shortWeekdaySymbols (returns an NSArray of 
NSStrings) and index into that with your weekday number.

Other than that, the correct way to do this is to construct an NSDate with the 
appropriate weekday and then use a date format of "EEE" to get the short 
weekday name.

Dave

On Oct 18, 2011, at 3:18 PM, Rick Mann wrote:

> Hi. Given a day-of-week number, what's the best way to get the abbreviated 
> name of that weekday? I've tried using NSDateComponents in various ways 
> (stand-alone, building off the current date, etc.) to get at it (by using 
> NSDateFormatter on the resulting date), but none seem to work. Basically, 
> setting the weekday on NSDateComponents seems to do nothing.
> 
> Matters are complicated by the fact that two of the three format specifiers 
> for weekday name use the "local" weekday number, which can vary by locale.
> 
> Any suggestions? I could just roll my own and localize it, but I'd rather 
> just use what the OS provides.
> 
> The only other thing I can think to do is start with a known date for, say, 
> Sunday, and add to that the weekday number I have, and the convert that date 
> to a string formatted as a weekday name.
> 
> Thanks,
> 
> -- 
> Rick
> 
> _______________________________________________
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/davedelong%40me.com
> 
> This email sent to davedel...@me.com

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to