开发者

How can I map tz database names to city and country names?

Is there a publicly available mapping from tz database (aka zoneinfo database, aka Olson database) IDs to city and country? For example:

"Pacific/Auckland" => "Auckland, New Zealand"
"Europe/Copenhagen" => "Copenhagen, Denmark"
"Europe/Paris" => "Paris, France"
"Europe/Moscow" => "Moscow, Russia"
"Asia/Tokyo" => "Tokyo, Japan"
"Asia/Baghdad" => "Baghdad, Iraq"
"Africa/Cairo" => "Cairo, Egypt"

... and so on.

Ideally, the mapping would:

  • be provided in different languages, such that "Europe/Paris" maps to "Paris, France" in English, "Paris, Frankrike" in Swedish and "パリ、フランス" in Japanese.
  • have multiple options for each tz entry to cover more cities. For example, Canberra (the capitol of Australia) is not in the tz database but it can be mapped to "Australia/Sydney"

The built-in World 开发者_JAVA百科Clock application on the iPhone achieves this. The timezone APIs on iOS rely on the tz database, but when selecting a timezone for a new world clock users can choose from "Canberra, Australia", "Sydney, Australia", "Baghdad, Iraq", "Paris, France", etc. The underlying NSTimeZone API that the World Clock app is likely using does not expose this information, therefore the data must be provided in the app, not in the underlying OS.

Does anyone know where this mapping can be found?


This code has a map of country names to timezones...

https://gist.github.com/986163

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜