奥尔森时区到窗口 [英] Olson time zone to windows

查看:27
本文介绍了奥尔森时区到窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在 Windows 中从 olson 时区转换时区.使用 PHP.

I need to convert a time zone from olson time zone in windows. Using PHP.

我发现了这个http://unicode.org/repos/cldr/trunk/common/supplemental/windowsZones.xml

使用这些数据进行转换似乎并不难.

It seems that it is not difficult to convert using this data.

但是有一些问题:

1) 我可以信任这个来源吗?

1) Can I trust this source?

2) 如何用多值解析类型:

2) How parse type with multi values:

<mapZone other="Eastern Standard Time" territory="US" type="America/New_York America/Detroit America/Indiana/Petersburg America/Indiana/Vincennes America/Indiana/Winamac America/Kentucky/Monticello America/Louisville"/>

用空格字符分隔?

  • 美国/纽约
  • 美国/底特律
  • 美国/印第安纳州/彼得堡
  • 美国/印第安纳州/文森斯
  • 美国/印第安纳州/威纳马克
  • 美国/肯塔基州/蒙蒂塞洛
  • 美国/路易斯维尔

但为什么有些区域有三个组成部分?

But why some zones have three components?

3) 转换奥尔森时区时总是存在 => Windows 时区将只接收 1 个时区或更多时区?在这种情况下该怎么办?

3) Always there when converting Olson time zone => Windows time zone will receive only 1 timezone or maybe more? And what to do in this case?

4) 有什么陷阱吗?例如UTC.

4) Are there any pitfalls? For example UTC.

推荐答案

是的,您可以信任该来源,它确实是用于此类转换的最佳来源.我使用相同的数据来实现.NET 的转换功能.

Yes, you can trust that source, and it is indeed the best source to use for this type of conversion. I have used the same data to implement the conversion functions for .NET.

由于您的问题是关于 PHP,我认为这不是一个重复的问题 - 尽管我很好奇您为什么要在 PHP 中执行此操作,因为 PHP 使用 IANA/Olson 时区,即使在 Windows 上也是如此.

Since your question is asking about PHP, I'll consider this not to be a duplicate question - though I'm curious why you want to do this in PHP, since PHP uses IANA/Olson time zones, even on Windows.

Windows 时区往往比 IANA 时区更宽,因此解释了映射中存在多个值的原因.该列表确实由空格分隔,并且 CLDR 规范要求列表中的第一个条目是 CLDR 的规范参考.

Windows time zones tend to be broader than IANA zones, thus explaining why multiple values exist in the mapping. The list is indeed separated by spaces, and the CLDR specs require that the first entry in the list be the canonical reference for the CLDR.

为什么有些区域具有三个组件与 CLDR 无关,但这些实际上是原始区域标识符.维基百科有很好的解释.

Why some zones have three components isn't related to CLDR, but these are actually the original zone identifiers. Wikipedia has a good explanation.

从 Olson 到 Windows 只有一个标识符 - 但不一定从 Windows 到 Olson.

There is only a single identifier going from Olson to Windows - but not necessarily from Windows to Olson.

是的,还有更多陷阱:

  • 并非所有 IANA/Olson 区域都可以映射到 Windows 区域 ID.示例:America/Atikokan

CLDR 和 IANA 不同意什么是规范.CLDR 规范 id 永远不会改变,而 IANA 规范 id 确实可以更改,用链接替换以前的 id.这使得从 Olson 映射到 Windows 有点困难,因为您必须检查所有链接.

CLDR and IANA disagree about what is canonical. CLDR canonical ids are never changed, while IANA canonical ids can indeed be changed, replacing the previous id with a link. This makes it a bit difficult to map from Olson to Windows, because you have to check all links.

例如,印度是 CLDR 中的 Asia/Calcutta.它已在 IANA tzdb 中更新为 Asia/Kolkata - 用链接替换 ​​Asia/Calcutta.要将 Asia/Kolkata 映射到 Windows印度标准时间",您必须根据映射检查该区域的所有链接.

For example, India is Asia/Calcutta in the CLDR. It has been updated in the IANA tzdb to Asia/Kolkata - replacing Asia/Calcutta with a link. To map Asia/Kolkata to the Windows "India Standard Time", you have to check all links for the zone against the mappings.

CLDR 将 Windows 的UTC"区域映射到Etc/GMT".IANA 将 Etc/UTC(和其他缩写)视为一个单独的区域 - 而不是链接.因此,您必须手动处理这些.

CLDR maps Windows "UTC" zone to "Etc/GMT". IANA considers Etc/UTC (and other abbreviations) as a separate zone - not a link. So, you have to handle these manually.

这篇关于奥尔森时区到窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆