且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

检查夏令时是否生效?

更新时间:2022-05-08 07:12:15

觉得你需要把这个 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);