将joda时区映射到Windows时区(例如,在C#中) [英] mapping joda timezone to windows timezone (for example in C#)

查看:61
本文介绍了将joda时区映射到Windows时区(例如,在C#中)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法将joda时区映射到Windows时区.

I'm having trouble mapping joda time zones to windows time zones.

我使用 CLDR映射的xml 适用于大多数翻译.

I use the xml of CLDR mappings, and it works for most of the translations.

尽管如此,它没有几个joda时区的值:

nevertheless, it doesn't have values for several joda time zones:

美国/印第安纳州/印第安纳波利斯,BST,澳大利亚/维多利亚州,环球影城, 澳大利亚/新南威尔士州,美国/Fort_Wayne,非洲/阿斯马拉, 美国/肯塔基州/路易斯维尔,亚洲/喀什,美国/太平洋地区,澳大利亚/西部, 澳大利亚/昆士兰州,澳大利亚/南部,美国/东部,美国/中部, 美国/亚利桑那州,澳大利亚/塔斯马尼亚州,新西兰,美国/山地,澳大利亚/尤克拉州,格林尼治标准时间, 日本,CAT,Etc/GMT + 0,CST,PST,EST,澳大利亚/堪培拉, 墨西哥/一般,以色列,加拿大/东部,Etc/GMT + 9,加拿大/中部, 澳大利亚/北部

America/Indiana/Indianapolis, BST, Australia/Victoria, Universal, Australia/NSW, America/Fort_Wayne, Africa/Asmara, America/Kentucky/Louisville, Asia/Kashgar, US/Pacific, Australia/West, Australia/Queensland, Australia/South, US/Eastern, US/Central, US/Arizona, Australia/Tasmania, NZ, US/Mountain, Australia/Eucla, GMT, Japan, CAT, Etc/GMT+0, CST, PST, EST, Australia/Canberra, Mexico/General, Israel, Canada/Eastern, Etc/GMT+9, Canada/Central, Australia/North

在哪里可以找到这些joda时区到Windows时区之间的映射?

Where can I find the mapping between these joda timezones to windows timezones?

推荐答案

使用纯CLDR数据:

如果它不是alias字段中的第一项,则使用第一项.示例:

If it's not the first entry in the alias field, then use the first entry. Example:

<type name="aumel" description="Melbourne, Australia"
                   alias="Australia/Melbourne Australia/Victoria"/>

您可以看到Australia/Victoria作为第二项,因此它是Australia/Melbourne的别名.请注意,CLDR的规范区域与TZDB的规范定义不完全匹配,因此请使用这些CLDR映射-而不是tzdb中的link条目.

You can see Australia/Victoria as the second item, so it is an alias to Australia/Melbourne. Note that CLDR's canonical zones are not exactly matched to TZDB's definition of canonical, so use these CLDR mappings - not the link entries from tzdb.

现在检查 /common/supplemental/windowsZones.xml 文件.示例:

Now check the /common/supplemental/windowsZones.xml file. Example:

<mapZone other="AUS Eastern Standard Time" territory="AU"
         type="Australia/Sydney Australia/Melbourne"/>

type字段包含一个或多个tzdb区域. other字段包含相应的Windows区域.

The type field contains one or more tzdb zones. The other field contains the corresponding Windows zone.

请注意,并非所有的tzdb区域都具有有效的对应Windows区域,有些不是 perfect 映射.

Be aware that not all tzdb zones have a valid corresponding Windows zone, and some are not perfect mappings.

  • 不完全映射的示例:America/Havana => Eastern Standard Time

  • DST过渡天一致,但古巴在午夜而不是凌晨2点进行过渡

不可映射区域的示例:Australia/Lord_Howe

Example of unmappable zone: Australia/Lord_Howe

  • 存在于timezone.xml中,但不存在于windowsZones.xml中.
  • 此位置当前没有Windows时区条目.

您的列表中有一些项目(BSTCATCSTPST)不是有效的tzdb区域,即使通过

You have a few items in your list (BST, CAT, CST, PST) that are not valid tzdb zones, even by Joda-Time's list. These could be abbreviations or rule names, but they are not zone identifiers.

这篇关于将joda时区映射到Windows时区(例如,在C#中)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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