All Forums
 Microsoft Windows CE
 .NET Application Development
 Setting the Time Zone
 Forum Locked
 Send Topic to a Friend
 Printer Friendly
Author Topic  

dcx

35 Posts

Posted - 01 Nov 2004 :  15:45:27  Show Profile  Email Poster
I have tried using SetTimeZoneInformation on my Graphics Client Plus (.NET 4.2), but it seems like no matter what value I put in, it always sets it to GMT. Is there a way around this? I want something similar to the CE system set Date/Time dialogue that can be called from my app so that when running without the desktop the user can set the date/time (and time zone) correctly.

ctacke

877 Posts

Posted - 01 Nov 2004 :  16:21:15  Show Profile  Email Poster
Once you set the time zone, the shell must be notified by broadcasting a WM_SETTINGSCHANGE message to the system. Be aware that if you change this while a managed app runs, the managed app does *not* know, and a call to something like DateTime.Now will not reflect the new bias you set. If you need to query the time again, you *must* P/Invoke GetLocalTime.
Go to Top of Page

dcx

35 Posts

Posted - 03 Nov 2004 :  13:07:48  Show Profile  Email Poster
I tried this and it doesn't seem to work. I was incorrect before, it appears to be stuck at Pacific time (GMT-8 hours).
I did SetTimeZoneInformation, setting the desired bias, sent WM_SETTINGCHANGE, and then called GetLocalTime. The timezone is still off when I open the windows date/time properties.
How do I change the timezone and get it to stick? Am I making the proper calls?
Go to Top of Page

ctacke

877 Posts

Posted - 03 Nov 2004 :  17:55:46  Show Profile  Email Poster
The shell/app is responsible for setting the text as well as the bias. Setting the bias to -7 doesn't automatically set the text to Mountain, you have to do that as well.
Go to Top of Page

dcx

35 Posts

Posted - 04 Nov 2004 :  11:47:31  Show Profile  Email Poster
I am confused, where would I be setting this text? After I do what I described above, the windows time is 8 hours off (in my app and in win ce), so I opened the win ce date/time system property and see that it is still Pacific Time.
Go to Top of Page

ctacke

877 Posts

Posted - 05 Nov 2004 :  09:55:50  Show Profile  Email Poster
Yes, it is confusing. Really the best example is the source for the existing control panel applet because it's not a simple or straightforward process. Take a look in the datetime.cpp file, which if you have a default directory install of PB resides at C:\WINCE420\PUBLIC\WCESHELLFE\OAK\CTLPNL\CPLMAIN\datetime.cpp
Go to Top of Page

dcx

35 Posts

Posted - 05 Nov 2004 :  16:38:44  Show Profile  Email Poster
Thanks, that helped to clarify things quite a bit.

There isn't a way to call this control panel app (date/time) when running without the desktop is there?
Go to Top of Page

akidder

1519 Posts

Posted - 10 Nov 2004 :  12:26:46  Show Profile  Email Poster
You might be able to call the applet, but it's probably better to do it programmatically. Would you like us to send you an evaluation version of Platform Builder? You could take a look at the datetime.cpp code that way.
Go to Top of Page

dcx

35 Posts

Posted - 23 Nov 2004 :  14:30:20  Show Profile  Email Poster
Thanks I downloaded the evaluation version.
Go to Top of Page

mplaum

11 Posts

Posted - 13 Jun 2007 :  12:53:25  Show Profile  Email Poster
You might want to try this:

The current timezone information is kept in a private static member of the TimeZone class called currentTimeZone. It is initialized once and then reused. The way to force it to refresh is to set it to null:
------------------
In C++:

using System.Reflection;
FieldInfo fi = typeof(TimeZone).GetField("currentTimeZone", BindingFlags.NonPublic|BindingFlags.Static|BindingFlags.Instance);

fi.SetValue(null, null);
------------------
In VB:

Imports System.Reflection

Dim tz as TimeZone = TimeZone.CurrentTimeZone

Dim fi as FieldInfo = tz.GetType().GetField("currentTimeZone",
BindingFlags.NonPublic OR BindingFlags.Static OR BindingFlags.Instance)

fi.SetValue(Nothing, Nothing)

------------------

Next time any time-formatting (or other timezone-dependent call is made), the CF will re-read the current TZ info from the operating system.


Edited by - mplaum on 13 Jun 2007 12:54:11
Go to Top of Page

Jim Najpauer

9 Posts

Posted - 14 Jun 2007 :  08:32:48  Show Profile  Email Poster
Quite interesting

Did you know that when the "Date/Time Properties" window is accessed and the 'OK' button is simply selected (i.e. without changing (applying) any information) a NOTIFICATION_EVENT_TZ_CHANGE (ref: Notify.h) will be generated.

The above occurs on our GCX with build 4.20.21
Go to Top of Page

ctacke

877 Posts

Posted - 14 Jun 2007 :  10:46:12  Show Profile  Email Poster
Yes, but the CLR doesn't look for that notification. Since it has no mechanism to internally change the TZ, it doesn't seem to believe it ever will change.
Go to Top of Page
  Topic  
 Forum Locked
 Send Topic to a Friend
 Printer Friendly
Jump To:
Eurotech Support Forums © Eurotech Inc. Go To Top Of Page
This page was generated in 0.05 seconds. Snitz Forums 2000