gpt4 book ai didi

.NET TimeZoneInfo 关于夏令时的错误

转载 作者:行者123 更新时间:2023-12-04 22:51:20 28 4
gpt4 key购买 nike

任何人都可以帮助理解这一点。 Microsoft 3.5 中的 TimeZoneInfo 类告诉我以下 GMT 日期不是东部时区的夏令时,但它是。

// 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 个网站说它处于夏令时:
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

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...



你也可以看看这个...

TimeZoneInfo.GetAmbiguousTimeOffsets Method

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

关于.NET TimeZoneInfo 关于夏令时的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4988693/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com