时区缩写缩写、时区

2023-09-02 10:28:56 作者:夜声带走最后一个我@

的TimeZoneInfo 不为给定的时区提供缩写或简称。唯一的好办法做到这一点是有一个字典,将映射缩写为 Timezone.id StandardName 或DaylightName 属性。然而,所有我搜索缩写的列表来源有不同的时区的名称,即不等同于Windows。

TimeZoneInfo does not provide abbreviation or a short name for a given Timezone. The only good way to do it is to have a dictionary that will map abbreviations to either Timezone.id, StandardName or DaylightName properties. However, all the sources I searched for list of abbreviations have different timezone names, i.e. not the same as in Windows.

如何显示用户不是全名,ID或.NET中的其他名字呢?我不希望UtcOffset但时区的缩写 - PST太平洋,UTC - 通用,EST - 东部标准等是否有任何C#兼容列表或数据库中所有可能的时区和它们的缩写,与那些兼容的 TimeZoneInfo.GetSystemTimeZones()给你?

How do you show a user not a full name, id or any other name in .NET? I don't want the UtcOffset but Timezone abbreviation - PST for Pacific, UTC - for Universal, EST - for Eastern Standard and etc. Is there any C# compatible list or database with all possible timezones and their abbreviations that compatible with those that TimeZoneInfo.GetSystemTimeZones() gives you?

推荐答案

这是一个棘手的要求,最好你能做的就是让你选择的列表,并创建一个扩展/ helper方法获取的缩写给出的TimeZoneInfo

This is a tricky requirement, the best you can do is get the list of your choice and create a extension / helper method to get the abbreviation for the given TimeZoneInfo.

在开始的地方是在http://www.timeanddate.com/library/abbreviations/timezones/其中有一个版本的名单,涵盖我知道的区域。

Once place to start is at http://www.timeanddate.com/library/abbreviations/timezones/ which has a version of list which covers the zones I am aware of.

这个问题是在选择合适的缩写,其中存在多个对于给定的时区。例如 UTC 可以重新presented为 UTC 或 WET(西欧时间)或 WEZ(Westeuropäische时代周报)或 WT(西撒哈拉标准时间)

The issue would be in selecting an appropriate abbreviation where more than one exists for a given timezone. For example UTC can be represented as UTC or WET (Western European Time) or WEZ (Westeuropäische Zeit) or WT (Western Sahara Standard Time).

您可能要同意你的利益相关者,你要遵循与给定的选择的命名约定。

You may want to agree with your stakeholders on the naming convention you are going to follow with the given choices.

 
精彩推荐