views:

84

answers:

2

BUG in IPHONE SDK 3.1 secondsFromGMT method of NSTimeZone Returning Wrong value Documentation says: secondsFromGMT Returns the current difference in seconds between the receiver and Greenwich Mean Time. This my Sample code

NSTimeZone *tZone =[NSTimeZone  timeZoneWithName:@"Asia/Calcutta"];
NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
[calendar setTimeZone:tZone];
NSLog([NSString stringWithFormat:@" seconds from GMT:%d",[tZone secondsFromGMT]);

I am getting sseconds from GMT:625272 as output it should be 19800

A: 

Sorry, but you’re wrong. See http://en.wikipedia.org/wiki/Kolkata or NSTimeZone-Documentation (knownTimeZoneNames – sorry, may not post more than one link).

Greetings

Objective Interested Person
Hi, I am sorry i couldn't able to understand anything in your answer TimeZone Asia/Calcutta(It is renamed as kolkatta before iphone OS is out. But that is Not updated yet ) has TimeZone offset from GMT is 5.5 that means (3600 seconds* 5.5) 19800 Should be the answer.Rite.
muthukumar
A: 

@ muthukumar: should I believe what you’re saying? At least within my snow leopard I just can’t select Calcutta. But with Kolkata everything is fine!

Greetings

Ojective Interested Person
KnownTimeZones API returns "Asia/Kolkata". API abbreviationDictionary has "Asia/Calcatta" only. But, I have tested with both timeZone names, API secondsFromGMT returns wrong wrong wrong value. It is not working according to the documentation. It's buggie.
muthukumar
I Don't how to make you believe this. But Sample code is given clearly in my ques. You have to believe or test that one.
muthukumar