Search code examples
swiftios8gpsnstimezone

Is there a way to get timezone for specific GPS coordinates in Swift iOS8


If I travel to a given part of the world iOS will automatically update the timezone. I'm curious if it uses GPS coordinates to do so, and if that's the case, are there any facilities in Swift to find out the timezone from a specific set of GPS coordinates?

I'm aware of NSTimeZone and none of its functions seem to do what I need. I'm calculating solar rise and set times for any specified location around the world. I.e. locations the user may not currently be in. However, the dates are returned in UTC so I need to be able convert those dates into their appropriate timezones.

The major constraint to this project, is that I can't use online API's such as GeoCities or Google.

I have considered using an offline database, I'm just seeing if Swift has a function I can use first.


Solution

  • Alright, after much searching I have found an acceptable solution. Alterplay has an objective-c library that can calculate timezones based off of gps coordinates without the need to use online services. For anyone that's curious the library can be found here: https://github.com/Alterplay/APTimeZones .