Setting timezone with application using OpenNETCF.WindowsCE

925 Views Asked by At

I'm developing an app for Windows Mobile 6.1 using the OpenNETCF Smart Device Framework, and I am trying to update the time zone of the Windows Mobile device from my application using the SetTimeZoneInformation call.

The timezone I'm trying to set it to is GMT-5 Eastern (New York time zone, which observes daylight saving time), but the system is selecting to GMT-5 Bogota, Lima (which does not observe daylight saving time).

To confirm if I am setting it correctly, after setting the time zone, I called GetTimeZoneInformation to see if the timezone what I set earlier is matching and it does. So, I don't know how this setting is getting messed up internally.

I found a similar question here, but there is no concise answer and there is a referenced link that is dead.

Here is some of the code I'm using:

var tzc = new TimeZoneCollection();
tzc.Initialize();

var currentTz = new TimeZoneInformation();
DateTimeHelper.GetTimeZoneInformation(ref currentTz);

var tziList = tzc.Cast<TimeZoneInformation>().ToList();
var configTzi = tziList.FirstOrDefault(i => i.StandardName == "Eastern Standard Time");

if (configTzi != null)
    if (currentTz.StandardName != configTzi.StandardName)
        DateTimeHelper.SetTimeZoneInformation(configTzi);

Any help would be greatly appreciated.

1

There are 1 best solutions below

0
On

Your code should work fine, but you said that New York time zone observes daylight saving time, so you may want to enable the Auto DST, which I could set by setting a key in the registry with that code :

const string key = @"HKEY_LOCAL_MACHINE\Software\Microsoft\Clock";
Registry.SetValue(key, "AutoDST", 1);

Hope this helps, Best regards

Didier