Re: NSDateFormatter not working on iOS 5.
Re: NSDateFormatter not working on iOS 5.
- Subject: Re: NSDateFormatter not working on iOS 5.
- From: Matt Neuburg <email@hidden>
- Date: Thu, 17 Nov 2011 10:14:50 -0800
On Wed, 16 Nov 2011 14:43:55 -0800, Peter Edberg <email@hidden> said:
>The change in parsing of abbreviated time zone names in iOS 5.0 is a result of an intentional change in the open-source ICU 4.8 library (and the open-source CLDR 2.0 data that it uses), a modified version of which is used to implement some of the NSDateFormatter functionality.
>
>The issue is this: With the *short* timezone formats as specified by z (=zzz) or v (=vvv), there can be a lot of ambiguity. For example, "ET" for Eastern Time" could apply to different time zones in many different regions. To improve formatting and parsing reliability, the short forms are only used in a locale if the "cu" (commonly used) flag is set for the locale. Otherwise, only the long forms are used (for both formatting and parsing).
>
>For the "en" locale (= "en_US"), the cu flag is set for metazones such as Alaska, America_Central, America_Eastern, America_Mountain, America_Pacific, Atlantic, Hawaii_Aleutian, and GMT. It is *not* set for Europe_Central.
>
>However, for the "en_GB" locale, the cu flag *is* set for Europe_Central.
>
>So a formatter set for short timezone style "z" or "zzz" and locale "en" or "en_US" will not parse "CEST" or "CET", but if the locale is instead set to "en_GB" it *will* parse those. The "GMT" style will be parsed by all.
>
>If the formatter is set for the long timezone style "zzzz", and the locale is any of "en", "en_US", or "en_GB", then any of the following will be parsed, because they are unambiguous:
>"Pacific Daylight Time"
>"Central European Summer Time"
>"Central European Time"
>
>Hope this helps.
Thanks; I suspected that something like this might be the case. But the result, as I pointed out in my bug report (10447767), is that you can't round-trip the abbreviations that the system itself gives you:
NSDictionary* d = (NSDictionary*)CFTimeZoneCopyAbbreviationDictionary();
for (NSString* aZone in d.keyEnumerator)
NSLog(@"%@ %@", aZone, [dateFormatter dateFromString:
[NSString stringWithFormat:@"2011-11-15 06:50:59.735 %@", aZone]]);
These are *your* abbreviations (by "you" I mean the system) that aren't working. If they aren't going to work why are you giving them to me? Surely there should be some call that provides me with a list of *legal* abbreviations. m.
--
matt neuburg, phd = email@hidden, <http://www.apeth.net/matt/>
A fool + a tool + an autorelease pool = cool!
Programming iOS 4!
http://www.apeth.net/matt/default.html#iosbook_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden