从 NSTimeZone 获取城市和国家

发布于 2024-08-13 09:03:00 字数 190 浏览 4 评论 0原文

我想(至少)获得时区的国家/地区名称。任何潜在方法都不会提供此信息:

  • name,
  • localizedName:locale:,
  • description

我注意到内置的 iPhone 时钟应用程序可以访问此信息,因为它将伦敦描述为“英国伦敦”。

谢谢。

I'd like to (at least) get the name of the country for a time zone. This is not provided by any of the potential methods:

  • name,
  • localizedName:locale:,
  • description

I notice that the built in iPhone clock App has access to this information, as it describes London as "London, England".

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

心头的小情儿 2024-08-20 09:03:00

我确信它与内置时钟的工作方式不同。有一个城市数据库,每个城市都有一个国家和一个时区。
您对[myGMT city]有何期望?都柏林还是卡萨布兰卡?

I'm sure that it works different with the built-in clock. There is a database of cities of which each has a country and a timezone.
And what would you expect from [myGMT city]? Dublin or Casablanca?

掌心的温暖 2024-08-20 09:03:00

timeZoneWithName:data: 方法,文件系统的时区信息位于 /usr/share/zoneinfo

我不知道文件的格式是什么,或者您是否可以从应用程序沙箱中读取它们,但这可能就是时钟应用程序获取信息的方式。

From the description of the timeZoneWithName:data: method, the filesystem has timezone information located at /usr/share/zoneinfo.

I have no idea what the format of the files is, or if you can even read them from the application sandbox, but that's likely how the Clock application gets the information.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文