Re: Getting the NSDateFormatter strings from the user's preferences
Re: Getting the NSDateFormatter strings from the user's preferences
- Subject: Re: Getting the NSDateFormatter strings from the user's preferences
- From: James Bucanek <email@hidden>
- Date: Thu, 19 May 2005 18:08:38 -0700
Sean McBride wrote on Thursday, May 19, 2005:
>On 2005-05-18 16:14, James Bucanek said:
>
>>Here's my second, annoying, question for the day. Where I can get the
>>date and time formatting strings set by the user in the International
>>Preferences Pane?
>>
>>And if you answer [NSUserDefaults standardUserDefaults], you'd be wrong.
>> These are not the formats set in the System Preferences. (I even dumped
>>every key in the standardUserDefaults dictionary to the console looking
>>for them, and they aren't in there.)
>>
>>I want to get the full, long, medium, and short date formats, and the
>>short time format strings as they have been customized by the user.
>
>So for example NSShortDateFormatString and NSDateFormatString aren't what
>you want? Could you elaborate on what your looking for?
As I said, I was looking for a format string, or a formatter, that would format dates according to the user customizable date and time setting the International Preference Pane.
The core foundation functions CFDateFormatter... intrinsicly fetch these formats and will format dates and time exactly as the user has requested.
It turns out that the date and time format strings in the NSUserDefaults are NOT these values. You can customize your date and time formatting preferences all day, and the strings in NSUserDefaults never change (and, they're not even very pretty to begin with).
Also, there are only two: NSShortDateFormatString and NSDateFormatString. The date formatting preferences in the International preference pane define four formats: Short, Medium, Long, and Full. These correspond to the CFDateFormatter styles CFDateFormatterShortStyle, CFDateFormatterMediumStyle, CFDateFormatterLongStyle, and CFDateFormatterFullStyle.
It's obvious that support for these four styles has been added to the NSDateFormatter class in 10.4, but I needed a pre-10.4 solution.
--
James Bucanek <mailto:email@hidden>
_______________________________________________
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