Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Thoroughly confused on date formatting



On Sep 29, 2006, at 10:36 AM, Matt Neuburg wrote:
Here is what I do:

NSDateFormatter *dateFormatter =
   [[[NSDateFormatter alloc] init] autorelease];
[dateFormatter setFormatterBehavior:NSDateFormatterBehavior10_4];
[dateFormatter setDateStyle:NSDateFormatterShortStyle];
[dateFormatter setTimeStyle:NSDateFormatterShortStyle];
NSMutableString* f =
   [NSMutableString stringWithString:[dateFormatter dateFormat]];

Aha, so now I have the user's preferences expressed as a mutable string in
ICU format. So now I mutate the string to combine the user's preferences
with my own (e.g. get rid of everything but hours and minutes, in your
case), and then:


[dateFormatter setDateFormat:f];

This can work, but not all the time. It isn't really possible to determine which constant strings go with which fields. If you get rid of the seconds, you also need to get rid of the string. Everyone is familiar with this case:


hh:mm:ss

but how about this one?

hh時mm分ss秒

In the first case, you get rid of the colon between mm and ss. In the second case, you get rid of the trailing character *after* ss.

This is a known problem, and is being worked on in ICU. See the description of "availableFormats" in:

http://www.unicode.org/reports/tr35/#Calendar_Elements

Deborah Goldsmith
Internationalization, Unicode liaison
Apple Computer, Inc.
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: http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >Re: Thoroughly confused on date formatting (From: Matt Neuburg <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.