http://www.cocoabuilder.com/archive/cocoa/310977-nsdateformatter-not-working-on-ios-5.html

See the explanation from Peter Edberg at Apple:

=====

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 theNSDateFormatter 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"

=========

m.

On Jan 31, 2012, at 10:54 AM, cocoa-dev-requ...@lists.apple.com wrote:

> Message: 9
> Date: Tue, 31 Jan 2012 12:37:08 -0600
> From: Heath Borders <heath.bord...@gmail.com>
> To: cocoa-dev <cocoa-dev@lists.apple.com>
> Subject: On iOS5 simulator and device,        NSDateFormatter doesn't show
>       time zone abbreviation for "Asia/Kolkata"       for the "z" or "zzz"
>       specifier.
> Message-ID:
>       <caey7hvokzeqwdcmchtx16bs4psp11uzk-91v6dwvdmngklc...@mail.gmail.com>
> Content-Type: text/plain; charset=UTF-8
> 
> On iOS5 simulator and device, NSDateFormatter doesn't show time zone
> abbreviation for "Asia/Kolkata" for the "z" or "zzz" specifier.
> 
> NSTimeZone *timeZone = [NSTimeZone timeZoneWithName:@"Asia/Kolkata"];
> NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
> dateFormatter.dateFormat = @"z"; // or @"zzz"
> dateFormatter.timeZone = timeZone;
> 
> NSLog(@"date string: %@", [dateFormatter stringFromDate:[NSDate
> date]]); // "GMT+05:30", expected "IST"
> NSLog(@"time zone abbreviation: %@", [timeZone
> abbreviationForDate:[NSDate date]]); // "IST"
> 
> I expect the above code to output
> 
> IST
> IST
> 
> but it outputs
> 
> GMT+05:30
> IST
> 
> Is this a bug? Am I doing something wrong?  People have mentioned that
> NSDateFormatter has bugs, especially when a time zone is specified in
> the format string.  Could this be one of those bugs?[1]
> 
> [1] http://stackoverflow.com/a/838934/9636
> 
> -Heath Borders
> heath.bord...@gmail.com
> Twitter: heathborders
> http://heath-tech.blogspot.com
> 


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to