本文介绍了检查夏令时是否生效?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何检查丹麦的夏令时是否已生效,如果是,则在我的数据中添加 1 小时,否则不会?我有一个 xml 文件:
How to check if in Denmark daylight time savings has taken effect, if so, then add 1 hour to my data, else not?I have a xml file:
<day = "1"
month = "5"
sunrise ="06:30"
sunset ="21:30"
/>
推荐答案
觉得你需要把这个 xml 转换成 DateTime 然后使用 TimeZoneInfo 类.
Think you need convert this xml to DateTime and then use TimeZoneInfo class.
如果丹麦是您的当地时间:
If Denmark your local time:
DateTime thisTime = DateTime.Now;
bool isDaylight = TimeZoneInfo.Local.IsDaylightSavingTime(thisTime);
否则您需要获取丹麦时区:
Else you need to get Denmark TimeZone:
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);
这篇关于检查夏令时是否生效?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!