Reputation: 33944
I need to convert the Timezone of my windows mobile 6.5 application to UTC in C# 4.0? Is it possible to change the timezone to UTC?
Upvotes: 0
Views: 2392
Reputation: 5959
You are confusing me. Windows Mobile 6.5 (aka Windows Embedded Handheld) AND C#4.0??????
Windows Mobile 6.5 can be programmed using the Compact Framework 3.5. There is no C# 4.0 version. There is Windows Phone (>=7.x) that can be programmed using a C# 4.0 framework. Latter is done with Visual Studio 2010. Windows Mobile 6.5 should be programmed with Visual Studio 2008 (latest VS with native Mobile support).
OK, when you deal with times, you should know that there are different 'times' known to your device. The main 'time', the system time, is always UTC. For example, filetimes are always saved with UTC. Otherwise switching the time zone would have to be saved to all files. Then there is a another 'time', the local time. For example DateTime.Now() gives the local time, the time with timezone and DST applied.
There are API functions to get/set UTC time of device or to get/set local time and to get/set filetimes.
Playing with SetTimeZone/GetTimeZone I found a big issue in conjunction with DST. See here http://www.hjgode.de/wp/2010/10/08/windows-mobile-setsystemtime-and-dst-einsteins-relativity-theory/. The post also has the P/Invokes to access time functions on Windows Mobile from Compact Framework.
What do you mean by Convert TimeZone to UTC? If you need to to knwo the UTC of a local time, you have to read the TimeZone information and add/remove the timezone offset values to the local time to get the UTC time.
~Josef
Upvotes: 1