如何在CultureInfo的性能得到时区 [英] How to get timezone from properties in CultureInfo

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

问题描述

我有一个字符串,其中包含时间戳(YYYY-MM-DD HH:MM:SS)。我可以根据我得到的其他信息创建一个CultureInfo对象。因此,我知道的时间戳是在哪个国家,时间戳是不是在UTC / GMT

I have a string, which contains a timestamp (yyyy-mm-dd hh:mm:ss). I can create a CultureInfo object based on other information I get. Therefore I know which country the timestamp is in. The timestamp is not in UTC/GMT.

说的时间戳是来自印尼(新的CultureInfo(ID-ID) ),这意味着该字符串被创造的 DateTime.Now.ToString(YYYY-MM-DD HH:MM:SS)的或相似的。这意味着字符串包含在印度尼西亚的本地时间。我知道的我的的时区,但我不知道该如何向印尼时间转换为UTC / GMT,这样我就可以的TimeZoneInfo使用UTC / GMT对象。我自己的时区可能会或可能不会在同一个时区。

Say the timestamp is from Indonesia (new CultureInfo("id-ID")), meaning the string was created by DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") or similar. That means the string contains the local time in Indonesia. I know my timezone, but I don't know how to convert the Indonesian time to UTC/GMT, so I can use the UTC/GMT object in TimeZoneInfo. My own timezone may or may not be in the same timezone.

在哪里有,这个信息连接?

Is there anywhere, this information is connected?

的CultureInfo有很多的属性,当然他们中的一些可以用来获取时区,somwhere?

CultureInfo has a lot of properties, surely some of them can be used to get timezone, somwhere?

我想补充一点,我觉得整个系统非常混乱,所以我可能是遥远的我是怎么想的事情工作

I might add that I find the entire system very confusing, so I could be way off in how I think things works.

推荐答案

简短的回答:没有。

龙答:这是文化和时区之间的1对多的关系。例如:
的en-US - 英语,美式包含6个时区...所以你会怎么从EN-我们去东部夏令时间? ......你怎么得到夏令时的偏移?

Long Answer: This is a 1 to many relationship between culture and timezone. For example: en-US - English, American contains 6 timezones... so how would you get from en-US to Eastern Daylight time? ... and how do you get the daylight savings time offsets?

这是一个令人困惑的难题文化(哇,尽量说的5倍快)是不是容易解决的CLR的。

It's a confusing cultural conundrum (wow, try saying that 5 times fast) that is not easily solvable with the CLR.

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

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