开发者

.NET: determine DST status for a given day in the past?

开发者 https://www.devze.com 2023-04-13 06:53 出处:网络
For a given date in the past, and assuming a US timezone, how can I use C# to determine whether or not Daylight Saving Time was in active for that day?

For a given date in the past, and assuming a US timezone, how can I use C# to determine whether or not Daylight Saving Time was in active for that day?

I have a timestamp for a given day in the past (开发者_Python百科the day and time were recorded separately) that I know would not have considered DST when recording itself, and I need to turn that timestamp into the local time of day (again, assuming a given US timezone) on which it was recorded, given the day on which it was recorded.


TimeZoneInfo.IsDaylightSavingsTime will do this. But, it might not be correct for the times previous to when they recently changed the period.


There are one or two implementations of the ZoneInfo db for .NET, for example http://www.babiej.demon.nl/Tz4Net/main.htm (the one used by Java and Unixes)

0

精彩评论

暂无评论...
验证码 换一张
取 消