使用 Objective C 获取给定 GMT 偏移量的时区缩写

发布于 2024-09-18 18:59:42 字数 335 浏览 2 评论 0原文

当只知道时间偏移量时,有没有办法查找时区缩写?

示例:假设给定了 GMT -5 的偏移量,我想显示 EST(假设为美国)的缩写,与 GMT -5 相对应。

如果使用 [NSTimeZone timeZoneWithName:@"America/Argentina/Buenos_Aires"] 初始化 NSTimeZone 对象,则可以通过 [myTzVar abbreviation]; 获得正确的缩写

但是,如果您使用 secondsFromGMT 对其进行初始化,缩写始终类似于“GMT -XXX”。

Is there a way to lookup a timezone abbreviation when only the temporal offset is known?

Example: Say i'm given the offset of GMT -5, i'd like to display the abbreviation of EST (assuming US) as apposed to GMT -5.

If you initialize a NSTimeZone object with [NSTimeZone timeZoneWithName:@"America/Argentina/Buenos_Aires"], you can get the correct abbreviation by [myTzVar abbreviation];

However, if you initialize it using secondsFromGMT, the abbreviation is always something like "GMT -XXX".

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

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

发布评论

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

评论(1

孤芳又自赏 2024-09-25 18:59:42

问题在于夏令时:对于具有相同 GMT 偏移量的国家/地区来说,夏令时可能会有所不同。这就是为什么只有提供全名而不仅仅是 GMT 偏移量才能知道缩写的原因。

The problem lies in daylight savings time: this can be different for countries that have the same GMT offset. That is why the abbreviation can only be known if you give the full name instead of just the GMT offset.

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