时区 [英] Time zones

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

问题描述

谁能解释为什么.Net不使用全面的枚举来表示所有世界时区?似乎当我们要转换时区时,时区被指定为字符串(例如"Mountain Standard Time")(请参阅TimeZoneInfo类).每个时区似乎 有本可以在枚举中使用的代码,但我看不到.请参阅本文:https://zh.wikipedia.org/wiki/List_of_time_zone_abbreviations

Can anyone explain why .Net doesn't use a comprehensive enum for representing all world time zones? It seems time zones are specified as strings (e.g 'Mountain Standard Time') when we want convert zones (see TimeZoneInfo class). Every time zone seems to have a code that could have been used in an enum but I dont see this. See this article: https://en.wikipedia.org/wiki/List_of_time_zone_abbreviations

推荐答案

在编译时为特定时区指定代码,但GMT可能除外.

You almost certainly do not want to specify code for a specific time zone at compile time, with the possible exception of GMT.

时区会随着使用时区的国家/地区的法律而变化.  将它们刻录到您的代码中并不是使应用程序过时的一种方法.

Time zones change with the laws of the nations that use them.  Burning them into your code is not a way to future-proof your application.


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

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