我们使用TimeZoneInfo.ConvertTimeFromUtc将UTC时间转换为当地时间等效值。转换为时区“中美洲标准时间”时,结果似乎不考虑夏令时。
根据此页面http://www.timeanddate.com/worldclock/city.html?n=24和我的客户,他们在德克萨斯州奥斯丁有夏令时
我的测试代码:
DateTime result;
DateTime utcTime = Convert.ToDateTime("20.04.2013 11:32:00");
try
{
TimeZoneInfo sourceTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Central America Standard Time");
result = TimeZoneInfo.ConvertTimeFromUtc(utcTime, sourceTimeZone);
}
catch (Exception)
{
result = Convert.ToDateTime("01.01.1900 00:00:00");
}
Console.WriteLine();
Console.WriteLine( Convert.ToString(result) );
Run Code Online (Sandbox Code Playgroud)
它给出了20.04.2013 05:32:00而不是20.04.2013 06:32:00(在DST中偏移了5小时)。我使用该方法是否错误?框架中的错误?Windows中的配置错误?
谢谢并恭祝安康
渣