Closed cblaze22 closed 6 years ago
Apple uses IANA time zones. Thus, this functionality already exists.
Also note your list above has many errors. I'd recommend using the TZConvert.WindowsToIANA
function from this library instead.
Actually I thought that too, but that is Apple's list they provide in code.
In what code?
Also, important to understand, due to the nature of time zones being political entities, this data changes regularly. I keep my library up-to-date with the changes so you can simply pull down the latest version. If you (or Apple or anyone really) have hard-coded a list somewhere, you're going to find it broken eventually as it ages.
Those timezones I listed is what Apple excepts in the code below, it is not pure IANA. The self.event.timeZone
is the timezones I have listed and translated from the Windows.
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setTimeZone:[NSTimeZone timeZoneWithName:self.event.timeZone]];
[dateFormat setDateFormat:@"yyyy-MM-ddHH:mm:ss"];
That code doesn't give a list of time zones or do any translation. Though I see it's part of your code here: https://stackoverflow.com/questions/43497252/ekeventstore-saveevent-adding-events-a-hour-later
I'm sorry, but your assertion is likely wrong, and you haven't explained how you translated. Did you do it yourself manually? Did Apple give you an API that returned Windows time zones? And how are you getting self.event.timeZone
anyway?
This article from Apple describes getting the list of all time zone names available on the system like so:
NSArray *timeZoneNames = [NSTimeZone knownTimeZoneNames];
Does that list actually include values with spaces around the slash like you have in your list above with "Pacific / Tongatapu"
?
You also have mismatches like timeZonesTranslation.Add("UTC+13", "GMT");
where it should include the inverted offset as in Etc/GMT-13
. And I'm pretty sure you're missing a lot of IANA zones and a few Windows ones.
Can you tell me specifically the values returned from the knownTimeZoneNames
function that is not a valid IANA zone?
As far as I can tell, those are all valid IANA time zone IDs. However, it is old data. It is at least older than version 2014b from what I can tell.
It also seems to be missing all zones from the etcetera
file, such as Etc/GMT+2
and others. I wonder if that is still the case in the current data? If so, that would be a limiting factor.
Please apply updates to your system and try the generating list again.
Note that this library only tracks the most current time zone data. It is presumed that targeted systems are kept up to date. Anything else would result in insanity. :wink:
You should add a conversion for Apple timezones.