Check if daylight savings is in effect?

前端 未结 8 1787
悲哀的现实
悲哀的现实 2020-12-29 02:14

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:



        
8条回答
  •  Happy的楠姐
    2020-12-29 03:08

    You can use TimeZoneInfo.IsDaylightSavingTime

    DateTime theDate = new DateTime(2012, 5, 1); // may 1st
    TimeZoneInfo tzi = TimeZoneInfo.FindSystemTimeZoneById("Central European Standard Time");
    bool isCurrentlyDaylightSavings = tzi.IsDaylightSavingTime(theDate);
    

提交回复
热议问题