Re: Localized dates and times
Re: Localized dates and times
- Subject: Re: Localized dates and times
- From: Chris Parker <email@hidden>
- Date: Mon, 12 Nov 2001 11:19:36 -0800
Marc,
With a locale set as you have it, you should be able to ask
NSUserDefaults for NSDateFormatString which will tell you what the
formatter is for that locale.
NSString *dateFormat = [[NSUserDefaults standardUserDefaults]
objectForKey:NSDateFormatString];
This worked for me with a "Language" setting of English and a "Date"
setting of French. It returns
%A %e %B %Y
with the default French settings
.chris
On Monday, November 12, 2001, at 10:55 AM, Marc Laffitte wrote:
I lost enough time searching for an answer, so let me ask you:
What I want to do should be relatively easy:
I just want to display an NSDate (or NSCalendarDate) in a text field
according to the user Date and Time settings in the International pane
of the system preferences.
So, even if the main system language is set to English, if I use French
for date and time, I would like something like: lundi 12 novembre 2001,
19h43
What I get for now is "lundi, novembre 12, 2001 18:00:53" if I do
somethiing like:
NSString * tDateString = [NSDate
dateWithTimeIntervalSince1970:myDateSince1970];
If instead of an NSDate I use an NSCalendarDate, I can set the format
to what I want but I don't know how to get the currents settings. (I
could read directly the pref file
/Users/<currentUser>/Library/Preferences/com.apple.HIToolbox.plist, but
I don't think this would be very clean).
However, with such a format, I get the day and months in english, not
french as set in my system preferneces...
If I connect my text field with an NSDateFormatter in my nib file, days
and months are displayed in the right language. But the format is fixed
to whatever is defined in the nib file. Even if I can choose an other
NSDateFormater, I still don't know how to get the current user settings.
I suppose I am missing something probably trivial, but...
I would appreciate any help.
Marc
PS: My system clock has also some difficulties in displaying dates the
correct way: It shows "lundi 11/12/2001 7:51" instead of "lundi
12/11/2001 19:51" according to my settings...
_______________________________________________
cocoa-dev mailing list
email@hidden
http://www.lists.apple.com/mailman/listinfo/cocoa-dev