What's the best way to compare two time zones?
I'm facing an issue while comparing two NSTimeZone
instances using - (BOOL)isEqualToTimeZone:(NSTimeZone *)aTimeZone
method.
NSString *timeZoneName = ...
NSTimeZone *sytemTimeZone = [NSTimeZone systemTimeZone];
NSTimeZone *selectedTimeZone = [NSTimeZone timeZoneWithName:timeZoneName];
if ([sytemTimeZone isEqualToTimeZone:selectedTimeZone])
isEqual = YES;
else
isEqual = NO;
Step 1: Go to Settings (Application) > General > Date & Time > Time Zone and search for "Austin". The entry that you'll get will be "Austin, U.S.A". Select this Time Zone. This SHOULD be your new system time zone now!
Step 2: Create a small iPhone/iPad application. Use [NSTimeZone knownTimeZoneNames]
to get a list of time zone names. Then try to find "Austin". It's not there! So, i guess we can use "America/Chicago" as the timezone?
Why is the Setting's timezone list different from ours?
Step 3: Now compare the system timezone with time zone for "America/Chicago". They don't match.
I've posted a bug for this - The bug is that Austin isn't in the known time zone list yet is offered by the settings app.
As per an Apple Engineer: