Changind TimeZone and notification without application restart

P

Peri

My app reads serialized DataTable containing DateTime columns. The file
can be moved between machines with different Time Zones. When I read
serialized DataTable on machine with different Time Zone (machine B) than
machine the DataTable was serialized on (machine A) I have to switch
TimeZone to same as that on machine A. Otherwise the DateTime columns are
converted to local time, and I don't want that. If I'm in GMT + 1 and
serialize DateTime column it is written like this:
2007-01-24T00:00:00+01:00. When I deserialize it on machine B with GMT +0
it is converted to 2007-01-23T23:00:00+00:00.

I've found way to change time zones. But I can't find a way to inform my
app (the same that is changing time zone) that time zone has changed. And
altought Time Zone is changed to GMT + 1 deserializing works like in GMT
+ 0. When I restart application it works ok. But I need to be able to
deserialize it using the TimeZone I switched to withour restarting my app.
I've tried:

uint msg = RegisterWindowMessage("WM_SETTINGCHANGE");
IntPtr HWND_BROADCAST = new IntPtr(0xffff);
IntPtr res;
IntPtr res2 = SendMessageTimeout(HWND_BROADCAST, msg, IntPtr.Zero,
IntPtr.Zero, SendMessageTimeoutFlags.SMTO_NORMAL, 1000, out res)

, but with no success.
 
O

Ollie Riches

As you probably know by now that TimeZones on the DateTime structure is not
supported in the current vesion 1.0 - 2.0 of the framework but 'should' be
supported in the future, check out the blog

http://blogs.msdn.com/kathykam/archive/2006/07/27/680593.aspx

HTH

Ollie Riches
My app reads serialized DataTable containing DateTime columns. The file
can be moved between machines with different Time Zones. When I read
serialized DataTable on machine with different Time Zone (machine B) than
machine the DataTable was serialized on (machine A) I have to switch
TimeZone to same as that on machine A. Otherwise the DateTime columns are
converted to local time, and I don't want that. If I'm in GMT + 1 and
serialize DateTime column it is written like this:
2007-01-24T00:00:00+01:00. When I deserialize it on machine B with GMT + 0
it is converted to 2007-01-23T23:00:00+00:00.

I've found way to change time zones. But I can't find a way to inform my
app (the same that is changing time zone) that time zone has changed. And
altought Time Zone is changed to GMT + 1 deserializing works like in GMT
+ 0. When I restart application it works ok. But I need to be able to
deserialize it using the TimeZone I switched to withour restarting my app.
I've tried:

uint msg = RegisterWindowMessage("WM_SETTINGCHANGE");
IntPtr HWND_BROADCAST = new IntPtr(0xffff);
IntPtr res;
IntPtr res2 = SendMessageTimeout(HWND_BROADCAST, msg, IntPtr.Zero,
IntPtr.Zero, SendMessageTimeoutFlags.SMTO_NORMAL, 1000, out res)

, but with no success.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top