如何检查丹麦夏令时是否生效,如果生效,则向我的数据添加 1 小时,否则不生效? 我有一个 xml 文件:
<day = "1"
month = "5"
sunrise ="06:30"
sunset ="21:30"
/>
最佳答案
认为您需要将此 xml 转换为 DateTime,然后使用 TimeZoneInfo 类。
如果丹麦是您本地时间:
DateTime thisTime = DateTime.Now;
bool isDaylight = TimeZoneInfo.Local.IsDaylightSavingTime(thisTime);
否则你需要获得丹麦时区:
DateTime thisTime = DateTime.Now;
// get Denmark Standard Time zone - not sure about that
TimeZoneInfo tst = TimeZoneInfo.FindSystemTimeZoneById("Denmark Standard Time");
bool isDaylight = tst.IsDaylightSavingTime(thisTime);
关于c# - 检查夏令时是否有效?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10665678/