Shahin Dohan
Shahin Dohan

Reputation: 6907

TimeZoneInfo DST vs Windows settings

Does TimeZoneInfo.SupportsDaylightSavingTime reflect the disabled/enabled status of "Adjust for daylight saving time automatically" in Windows date & time settings?

I'm trying to replicate those settings in a kiosk mode app where Windows is inaccessible for the user, and I've managed to get everything working including setting timezones with or without DST using tzutil, but while testing I noticed that some timezones DST settings (like Moscow) were not in sync with Windows.

We know that Russia got rid of DST a few years ago, so when I go to Windows and choose Moscow as my timezone, I see this:

Adjust for DST automatically is off, because it's not supported?

When starting my test console application (.NET 4.6.1), then fetch my current timezone from GetSystemTimeZones, I see that it actually does support DST:

DST is supported

If SupportsDaylightSavingTime is true, shouldn't the toggle switch be enabled in Windows settings?

I even went as far as testing by calling the Win32 function GetDynamicTimeZoneInformation to check whether DynamicDaylightTimeDisabled is true or false (although I'm not entirely sure if this reflects the settings in Windows either). I first tried with my real Timezone (Helsinki) and the results were:

When toggle swtich is on, DynamicDaylightTimeDisabled is false, but when the toggle is off, it becomes true. So I assumed that it probably does reflect it?

I tried with Russia, and the value for DynamicDaylightTimeDisabled is false, so daylight is enabled?

My Windows version is 10.0.17134 Build 17134 if that helps.

I'm really confused about this and would really appreciate some help. Thank you!

Upvotes: 4

Views: 313

Answers (1)

Shahin Dohan
Shahin Dohan

Reputation: 6907

The reason, as glenebob points out in his comment, is because there are no adjustment rules in effect after 2014 which is when Russia decided not to use DST anymore.

The Russian timezone does support DST, but only before 2014, so what I really had to do was to call the TimeZoneInfo.GetAdjustmentRules to figure out whether DST is valid at this point in time or not.

The app I'm developing is also using UWP API's, which is actually missing this method, but that's a whole different problem...

I was on a wild goose chase there for a while... We live and learn...

UPDATE: I decided not to replicate Windows by checking the adjustment rules. Little value for too much effort and complexity. No thanks!

Upvotes: 2

Related Questions