• 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: NSDateFormatter formats from NSLocale
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSDateFormatter formats from NSLocale


  • Subject: Re: NSDateFormatter formats from NSLocale
  • From: Christopher Kane <email@hidden>
  • Date: Wed, 12 Aug 2009 08:49:20 -0700

You can call [[NSLocale currentLocale] localeIdentifier], to get the locale identifier of the user's preferred locale, and then create another NSLocale from it. This will be a locale that doesn't have any (not just formatting) user preference overrides in it but is still the user's preferred base locale. That might be close to what you want.

Contrary to popular opinion [not just yours], NSLocale and NSDateFormatter also do not know the element orders. They just pass off the work to lower-level libraries, which -- as far as I understand it -- also do not themselves directly know what the order is (only indirectly through sets of format strings). For one thing, the Short date format for a locale might have one order, the Medium another, the Long yet another, and so on.


Chris Kane Cocoa Frameworks, Apple


On Aug 11, 2009, at 9:51 AM, Houdah - ML Pierre Bernard wrote:

Hi Sean,

I want to respect the user's locale, yet ignore his/her preferences as to formatting.

I thought about modifying the format I get from the standard styles. I would however expect NSLocale to know the correct order of elements in the date format.

Pierre

So you want to use the user's preference and yet you don't. The choice
of leading zeros or no is part of the user's choice. But if you must,
you could get the user's format string and carefully alter it to add
leading zeros.


--
____________________________________________________________
Sean McBride, B. Eng                 email@hidden
Rogue Research                        www.rogue-research.com
Mac Software Developer              Montréal, Québec, Canada


_______________________________________________

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


References: 
 >NSDateFormatter formats from NSLocale (From: Houdah - ML Pierre Bernard <email@hidden>)
 >Re: NSDateFormatter formats from NSLocale (From: "Sean McBride" <email@hidden>)
 >Re: NSDateFormatter formats from NSLocale (From: Houdah - ML Pierre Bernard <email@hidden>)

  • Prev by Date: Re: Adding more and more key/value observers is much too slow - workaround needed.
  • Next by Date: Re: Rescheduling an NSTimer from a completion method
  • Previous by thread: Re: NSDateFormatter formats from NSLocale
  • Next by thread: Re: NSDateFormatter formats from NSLocale
  • Index(es):
    • Date
    • Thread