检查夏令生效? [英] Check if daylight savings is in effect?
本文介绍了检查夏令生效?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何检查是否在丹麦日光节约时间已经生效,如果是这样,然后在1小时添加到我的数据,否则不?
我有一个XML文件:
<天=1
月=5
日出=06:30
日落=21:30
/>
解决方案
你觉得你需要这个XML转换为DateTime,然后用。的TimeZoneInfo类
如果丹麦本地时间:
日期时间thisTime = DateTime.Now;
布尔isDaylight = TimeZoneInfo.Local.IsDaylightSavingTime(thisTime);
否则,你需要得到丹麦时区:
的DateTime thisTime = DateTime.Now;
//获得丹麦标准时区 - 不知道这一点
的TimeZoneInfo TST = TimeZoneInfo.FindSystemTimeZoneById(丹麦标准时间);
布尔isDaylight = tst.IsDaylightSavingTime(thisTime);
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"
/>
解决方案
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);
这篇关于检查夏令生效?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文