• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Getting weekday name from weekday number?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Getting weekday name from weekday number?


  • Subject: Getting weekday name from weekday number?
  • From: Rick Mann <email@hidden>
  • Date: Tue, 18 Oct 2011 15:18:58 -0700

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 (email@hidden)

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Getting weekday name from weekday number?
      • From: Dave DeLong <email@hidden>
  • Prev by Date: Re: Blocks vs. life, the universe and everything
  • Next by Date: Re: Getting weekday name from weekday number?
  • Previous by thread: Re: How to get key code from "SysDefined" Carbon Event
  • Next by thread: Re: Getting weekday name from weekday number?
  • Index(es):
    • Date
    • Thread