.NET的TimeZoneInfo错了夏时制 [英] .NET TimeZoneInfo wrong about Daylight savings

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

问题描述

谁能帮助理解这一点。 3.5微软的TimeZoneInfo类是告诉我下面的GMT日期不在夏令东时区,但它是。

Can anyone help make sense of this. Microsoft’s TimeZoneInfo class in 3.5 is telling me the following GMT date is not in Daylight savings for the Eastern timezone, but it is.

// Get Eastern Timezone
TimeZoneInfo tzEasternZone = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");

// Convert to EST 
DateTime easternTime = TimeZoneInfo.ConvertTime(DateTime.Parse("2009-11-01T05:00:00Z"), tzEasternZone);

// Daylight saving IS in effect on this date, but Microsoft doesn't think so
Boolean isDaylight = easternTime.IsDaylightSavingTime();

下面的2个网站说,它是在夏令时:
<一href="http://www.timeanddate.com/worldclock/converted.html?month=11&day=1&year=2009&hour=5&min=0&sec=0&p1=0&p2=198" rel="nofollow">http://www.timeanddate.com/worldclock/converted.html?month=11&day=1&year=2009&hour=5&min=0&sec=0&p1=0&p2=198
http://www.timezoneconverter.com/cgi-bin/tzc.tzc

Here are 2 websites saying it is in daylight savings:
http://www.timeanddate.com/worldclock/converted.html?month=11&day=1&year=2009&hour=5&min=0&sec=0&p1=0&p2=198
http://www.timezoneconverter.com/cgi-bin/tzc.tzc

推荐答案

请参阅: TimeZoneInfo.IsDaylightSaving

由于该   TimeZoneInfo.IsDaylightSavingTime(日期时间)   方法可以返回错误的日期和   时间是不明确的(即,一个   的日期和时间,可以重新present   无论是标准时间或日光   节省时间在特定时间   区),则将   TimeZoneInfo.IsAmbiguousTime(日期时间)   方法可以与配对   IsDaylightSavingTime(日期时间)方法   以确定的时间是否可以是   夏令时。因为一个   暧昧时间是一个既可以是   夏令时间和标准   时间...

Because the TimeZoneInfo.IsDaylightSavingTime(DateTime) method can return false for a date and time that is ambiguous (that is, a date and time that can represent either a standard time or a daylight saving time in a particular time zone), the TimeZoneInfo.IsAmbiguousTime(DateTime) method can be paired with the IsDaylightSavingTime(DateTime) method to determine whether a time may be a daylight saving time. Because an ambiguous time is one that can be both a daylight saving time and a standard time...

另外你可以看看这个...

Also you might look at this...

<一个href="http://msdn.microsoft.com/en-us/library/system.timezoneinfo.getambiguoustimeoffsets.aspx">TimeZoneInfo.GetAmbiguousTimeOffsets方法

返回有关可能的日期和时间不明确的日期和时间可以被映射到信息。

Returns information about the possible dates and times that an ambiguous date and time can be mapped to.

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

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