Where is the iPhone's Date & Time getting its time zone list

后端 未结 3 983
滥情空心
滥情空心 2020-12-17 05:20

I can get a list of time zones with [NSTimeZone knownTimeZoneNames], but that only gives the time zone IDs which include one or two cities in each time zone.

相关标签:
3条回答
  • 2020-12-17 05:51

    Only 2? On 3.1 the [NSTimeZone knownTimeZoneNames] returns an array of 401 elements, and there are much less than 200 timezones on the Earth.

    I'm pretty sure "other apps" use +knownTimeZoneNames as well, since this is the only public method returning such list. Please make sure your code is correct, though.


    Settings.app uses the private CPCity API from the private AppSupport.framework. It does have San Francisco, but it's private.

    You need to create your own database (the data can be copied from /System/Library/PrivateFrameworks/AppSupport.framework/all_cities_adj.plist).

    0 讨论(0)
  • 2020-12-17 05:53

    What you are asking for is commonly referred to as the Olson database. See for instance this Wikipedia page. The public domain Zone.tab file contains all of the timezones. You can find a zones.tab file in the zoneinfo directory of the libical distribution.

    0 讨论(0)
  • 2020-12-17 05:54

    I know it might be a late answer, but just in case someone else stumbles on it like I did the other day. I just open sourced a library that does exactly this. It is available as a CocoaPod and you can find it here:

    https://github.com/gligorkot/TimeZonePicker

    Also, thanks for all the replies above, they helped me in finding the correct cities database that is used for the Settings app.

    0 讨论(0)
提交回复
热议问题