Where iPhone Date & Time gets its list of time zones

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

Date and time settings have a large list of cities, and I have seen several other applications that have the same, if not similar, search lists.

Where do these lists come from?

I need to associate the selected city with its time zone, such as Date and Time.

+4
source share
3 answers

Only 2? In version 3.1, t [NSTimeZone knownTimeZoneNames] returns an array of 401 elements, and on Earth there are much less than 200 time zones.

I am sure that "other applications" use +knownTimeZoneNames , as this is the only public method returning such a list. Make sure your code is correct.


Settings.app uses the private CPCity API from the private AppSupport framework. He has San Francisco, but he is private.

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

+7
source

What you ask for is usually called the Olson database. See for example this page on Wikipedia . The public Zone.tab file contains all time intervals. The zone.tab file can be found in the zoneinfo libical directory .

+2
source

I know this may be a late answer, but just in case, someone stumbles upon it, as if I were the other day. I just open a library that does just that. It is available as CocoaPod and you can find it here:

https://github.com/gligorkot/TimeZonePicker

In addition, thanks for all the answers above, they helped me find the correct city database that is used for the Settings app.

+1
source

Source: https://habr.com/ru/post/1312026/


All Articles