• 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
Re: Two questions about NSCalendar
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Two questions about NSCalendar


  • Subject: Re: Two questions about NSCalendar
  • From: Chris Kane <email@hidden>
  • Date: Thu, 19 Jan 2006 16:38:30 -0800

On Jan 18, 2006, at 4:44 PM, Nick Zitzmann wrote:

So I'm reading through the documentation on NSCalendar, and there's two things I don't understand, and I couldn't find mentioned in the archives:

1. How do I get the number of eras in a calendar? I see how to get the number of months in a year, days in a month, etc. but I see no way of getting the number of eras in a calendar.

There is no larger unit for the relative question (how many X in Y) to make sense, so the basic range of unit query gives the number of eras: [cal maximumRangeOfUnit:NSEraCalendarUnit]. For the Japanese calendar, the answer is {0, 236} [currently and hopefully for many many years to come].



2. How do I get the human-readable names of months, weekdays, and eras for a given calendar type (e.g. month 9 is "September" on the Gregorian calendar and "Ramadan" on the Islamic calendar)? If there is no way of doing this, then how does the International preference pane pull this off?

Text localization is left to the date formatter (NSDateFormatter of course). This is how the underlying ICU library distributes the knowledge responsibilities, and the NS APIs just reflect that.


Though, since we eventually added -setLocale: to NSCalendar (before Tiger shipped), NSCalendar could have a redundant set of methods to answer the questions. However, in some locales or languages the proper form of the month name depends on the context in which it is used, and that's more the purview of a formatter.


Chris Kane Cocoa Frameworks, Apple

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Two questions about NSCalendar
      • From: Nick Zitzmann <email@hidden>
References: 
 >Two questions about NSCalendar (From: Nick Zitzmann <email@hidden>)

  • Prev by Date: Re: NSTask -launch Freezes
  • Next by Date: reset textcontainer size?
  • Previous by thread: Re: Two questions about NSCalendar
  • Next by thread: Re: Two questions about NSCalendar
  • Index(es):
    • Date
    • Thread