TimeZones, Daylight Savings nightmare

G

Guest

Hi,

I've already found out that .Net Framework 1.1 does not properly handle
anything that is related to a non-current timezone. Since my project should
be released before the release of Framework 2.0, I am kindly asking if
anybody knows a workaround for the following:

My database stores various locations, and for each location we store a GMT
offset (number of hours). When the user selects a location, the program can
instantly obtain the GMT offset of this location. Then I take the
DateTime.UTCNow and add the offset to that value. As a result I am getting a
DateTime that holds the current date and time for a location that is in a
timezone that is different to the current machine setting. However, this
value will only be correct for the standard time (because we store the
standard offset in the DB). I have to determine if that timezone is currently
applying the daylight savings. If yes, I can add/substract 1 hour from my
variable. Question: how can I determine the daylight savings for a different
timezone?

Any references to the existing free components or code snippets or
explanations will be highly appreciated.

Note: I am happy to change the way we store the GMT offset (e.g. store the
standard timezone name instead) if required. Reading the registry will be
fine too, just tell what and where to read.

Thanks in advance,

Anna
 
C

Chris R. Timmons

Hi,

I've already found out that .Net Framework 1.1 does not properly
handle anything that is related to a non-current timezone.
Since my project should be released before the release of
Framework 2.0, I am kindly asking if anybody knows a workaround
for the following:

My database stores various locations, and for each location we
store a GMT offset (number of hours). When the user selects a
location, the program can instantly obtain the GMT offset of
this location. Then I take the DateTime.UTCNow and add the
offset to that value. As a result I am getting a DateTime that
holds the current date and time for a location that is in a
timezone that is different to the current machine setting.
However, this value will only be correct for the standard time
(because we store the standard offset in the DB). I have to
determine if that timezone is currently applying the daylight
savings. If yes, I can add/substract 1 hour from my variable.
Question: how can I determine the daylight savings for a
different timezone?

Any references to the existing free components or code snippets
or
explanations will be highly appreciated.

Note: I am happy to change the way we store the GMT offset
(e.g. store the
standard timezone name instead) if required. Reading the
registry will be fine too, just tell what and where to read.

Anna,

I don't believe there is anywhere in .Net or the Windows API where a
daylight savings time (DST) calculation method like this can be
found.

If you've ever installed Windows, you may remember the installer
asking you to set the time zone you were in and whether you wanted
DST turned on. This information is stored in the registry, and
that's the information the .Net TimeZone class is using.

Calculations involving time zones are easy, as the time zones around
the world are standardized. DST, however, is dependent upon local
laws. Different locations in the same time zone can have different
DST settings.

To get an idea of how complex the issue is, go to
http://www.timeanddate.com/time/ and look in the "DST dates" section.
 
C

clintonG

Hello -- and wierder yet -- is the fact that my use of the ASP.NET 2.0
Website Administration Tool (WAT) is recording users to the aspnet_Users
table 6 hours into the future on the XP Pro 1 machine being used to develop
the application. This local machine is synchronized to GMT (-06:00). The
fact that the offset of the WAT anomaly coincides with the GMT offset is a
mystery it is probably going to require Sir Sherlock Holmes to solve.

The consensus amongst those I have attempted to discuss this with seems to
suggest we should never install a "dot oh" release on the same disk where
previous beta instances were once installed. As applied to my current
experience it would imply the presence of a time broker on the machine. A
time broker that was installed by the beta. A time broker which still exists
on the machine causing a conflict with 2.0 that was RTM.

However, because I've never known of such a broker and because the system
time is stored in the registry and because the system time should be the
time a user is added to a database how could an application such as the WAT
arbitrarily record a write operation to the database and impose a 6 hour
offset?

Time is a funny thing.

<%= Clinton Gallagher
METROmilwaukee (sm) "A Regional Information Service"
NET csgallagher AT metromilwaukee.com
URL http://metromilwaukee.com/
URL http://clintongallagher.metromilwaukee.com/
 
G

Guest

I think there's some info in the Culture/CultureInfo classes...
By the way, .NET 2.0 was released on the 7th of November.
 

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