Re: formatting NSDate
Re: formatting NSDate
- Subject: Re: formatting NSDate
- From: Ian Spackman <email@hidden>
- Date: Tue, 18 Feb 2003 09:51:04 +0000
Martedl, febbraio 18, 2003, alle 04:18 , Michael Tsai ha scritto:
Here's the code I'm using to print time-date strings:
@implementation NSDate (MJT)
- (NSString *)mjtShortTimeDateString
{
NSString *format = [NSString stringWithFormat:@"%@ %@",
[defaults stringForKey:NSShortDateFormatString],
[defaults stringForKey:NSTimeFormatString]];
// ensure AM/PM if 12-hour
if ( [format mjtContainsString:@"I"] &&
![format mjtContainsString:@"%p"] )
format = [format stringByAppendingString:@"%p"];
// doesn't localize if you pass nil
NSDictionary *locale = [defaults dictionaryRepresentation];
return [self descriptionWithCalendarFormat:format
timeZone:nil
locale:locale];
}
@end
--
That's much closer than I managed when I tried to get an
internationalized time format. But it won't work for the default
Austrian, German or Swiss German time formats where the am/pm designator
"Uhr" is used for the 24 hour clock but not for the 12 hour clock.
Cheers,
Ian
email@hidden
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.