TimeZone.CurrentTimeZone doesn't update

G

Guest

I'm seeing TimeZone.CurrentTimeZone accurately reflecting the machine time
zone at the point that the assembly loads, but if the user subsequently
changes the Windows time zone the value of TimeZone.CurrentTimeZone doesn’t
change to reflect that.
In other words, if the system is on PST when my assembly loads then whenever
time I instantiate a TimeZone object
(System.TimeZone tz = System.TimeZone.CurrentTimeZone;)
the value of tz.StandardName returns "Pacific Standard Time" and
tz.GetUtcOffset comes back as -08:00:00 - even if I change to Brisbane time
(+10:00:00)

Is there some trick to this that I'm missing?

I've got an Outlook add-in that's passing date values to a web service. Even
though it works in UTC internally, the SOAP proxy classes expect values in
local time to which the parser then assigns an offset. The conversions to and
from UTC continue to use the original offset even if the user changes time
zones, which corrupts the data.
 
G

Guest

The cultureinfo is cached when retrieved from windows. Call the following
function to empty the cache. This will cause things like the timezone to be
reloaded:
System.Globalization.CultureInfo.CurrentCulture.ClearCachedData();

Ciaran O'Donnell
 

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