International date formatting
International date formatting
- Subject: International date formatting
- From: Ben Kazez <email@hidden>
- Date: Fri, 20 May 2005 01:45:18 -0500
Hi,
I'm new to Cocoa internationalization. Is there a way to format an
NSDate according to the current locale so that it displays the
weekday, full month name, and date but no year? In other words, in US
English I want:
Thursday, May 19
In French from France, this would be (I think):
vendredi 19 mai
etc.
Right now I'm using the following code, but it doesn't include the
year and worse, it's not changing based on System Preferences >
International:
dateFormatter = [[NSDateFormatter alloc]
initWithDateFormat:@"" allowNaturalLanguage:NO];
[dateFormatter
setFormatterBehavior:NSDateFormatterBehavior10_4];
[dateFormatter setDateStyle:NSDateFormatterFullStyle];
[dateFormatter setTimeStyle:NSDateFormatterNoStyle]; //
don't display the time
[dateFormatter setLocale:[NSLocale currentLocale]];
...
NSString *ret = [dateFormatter stringFromDate:[NSDate
dateWithTimeIntervalSince1970:(milliseconds/1000.0)]];
Thanks so much for your help!
Ben
--
Ben Kazez
http://www.benkazez.com/
_______________________________________________
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