Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if daylight savings is in effect?

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" /> 
like image 261
Megaoctane Avatar asked May 19 '12 13:05

Megaoctane


People also ask

How do you know if DST is in effect?

To check if DST (Daylight Saving time) is in effect:Check if the greater of the two values is not equal to the offset for the original date.

How do you test for DST?

Test transition of DST, i.e. when you are currently in summer time, select a time value from winter. Test boundary cases, such as a timezone that is UTC+12, with DST, making the local time UTC+13 in summer and even places that are UTC+13 in winter.

Will my phone know its daylight savings?

Most smartphone clocks will automatically adjust, if the phone's software is up to date. However, if you went into the settings and changed any of the default settings, you may have to update your clock yourself once daylight saving time ends.

What time zones are not affected by daylight savings?

There are two time zones that do not observe daylight saving time and that have the same UTC offset (-06:00): (UTC-06:00) Central America. (UTC-06:00) Saskatchewan.


1 Answers

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); 
like image 91
Eugene Avatar answered Oct 12 '22 14:10

Eugene