On iOS5 simulator and device, NSDateFormatter doesn't show time zone abbreviation for "Asia/Kolkata" for the "z" or "zzz" specifier.
On iOS5 simulator and device, NSDateFormatter doesn't show time zone abbreviation for "Asia/Kolkata" for the "z" or "zzz" specifier.
- Subject: On iOS5 simulator and device, NSDateFormatter doesn't show time zone abbreviation for "Asia/Kolkata" for the "z" or "zzz" specifier.
- From: Heath Borders <email@hidden>
- Date: Tue, 31 Jan 2012 12:37:08 -0600
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
email@hidden
Twitter: heathborders
http://heath-tech.blogspot.com
_______________________________________________
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