I'm writing an application that involves people's birth times, and I'm attempting to use IOS to get the accurate GMT offset. I'm getting what are clearly wrong answers, and I wonder whether others have encountered them, or if there are any workarounds.
Here's the code I'm using to compute the offset (first line), and the logging code to show what I've got.
ret.dateTime.offset = [tz secondsFromGMTForDate:date] / 3600.0;
double dstOffset = [tz daylightSavingTimeOffsetForDate:date] / 3600.0;
NSLog(@"Setting offset for %@ on %@, to %3.1f", ret.location.description, ret.dateTime.briefDateDescription, ret.dateTime.offset);
NSLog (@" (TZ Name = %@, date = %@, dstOffset = %3.1f)", tz.name, date, dstOffset);
Here are the results - correct for Plymouth and New York, which are in Eastern time, and the DST offset is correct for all of them, but secondsFromGMTForDate is off by one hour for Minneapolis (in Central time), and off by an hour in the other direction for Atlanta (in Eastern time).
Setting offset for Minneapolis, MN on 3/26/70, to -5.0
(TZ Name = America/Menominee, date = 1970-03-26 14:29:00 +0000, dstOffset = 0.0)
Setting offset for Plymouth, MA on 1/13/80, to -5.0
(TZ Name = America/New_York, date = 1980-01-14 02:52:00 +0000, dstOffset = 0.0)
Setting offset for Atlanta, GA on 10/10/48, to -6.0
(TZ Name = America/Kentucky/Monticello, date = 1948-10-10 13:07:00 +0000, dstOffset = 0.0)
Setting offset for New York, NY on 6/11/80, to -4.0
(TZ Name = America/New_York, date = 1980-06-11 12:25:00 +0000, dstOffset = 1.0)
Any clues? What do others get when they try Minneapolis on 3/26/70? America/Menominee is definitely central time, and with a DST Offset of 0, the secondsFromGMTForDate should definitely be -6 hours, not -5.