473,396 Members | 2,002 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

TimeZones, Daylight Savings nightmare

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
Nov 24 '05 #1
3 5221
"=?Utf-8?B?QW5uYQ==?=" <An**@discussions.microsoft.com> wrote in
news:9A**********************************@microsof t.com:
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.

--
Hope this helps.

Chris.
-------------
C.R. Timmons Consulting, Inc.
http://www.crtimmonsinc.com/
Nov 24 '05 #2
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/
"Chris R. Timmons" <crtimmons@X_NOSPAM_Xcrtimmonsinc.com> wrote in message
news:Xn**********************************@207.46.2 48.16...
"=?Utf-8?B?QW5uYQ==?=" <An**@discussions.microsoft.com> wrote in
news:9A**********************************@microsof t.com:
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.

--
Hope this helps.

Chris.
-------------
C.R. Timmons Consulting, Inc.
http://www.crtimmonsinc.com/

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

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Bathroom_Monkey | last post by:
For posterity's sake, here is an algorithm I created to take a GMT time and convert it to U.S. central time, accounting for daylight saving time. Note: this algorithm can be modified to work for...
0
by: Symon R | last post by:
This is a bit of a weird one that I haven't yet been able to solve - I'm hoping someone out there can disprove my findings and tell me where I've gone wrong! I have designed a web service that...
13
by: Michael | last post by:
I would like to set the timezone of a thread to allow me to calculate the UTC time for data sourced from a number of time zones. Although this can be done in C and C++, I annot find how to do...
1
by: Ryan Ternier | last post by:
We're implementing Daylight savings time in our new software, and I'm having an issue codeing it. We're storing: Month (ie: 10) WeekDay (ie: Sunday) WeekNumber (ie: 3 - 3rd Sunday in the...
4
by: Martijn van Oosterhout | last post by:
Hi, The operating system I run (Linux) comes with many, many timezone files for many different places in the world. For example: $ TZ='Australia/Sydney' date Fri Oct 8 06:15:31 EST 2004 $...
0
by: Bill | last post by:
My computer is a client in the central timezone with daylight savings. I need to pass a time and a value to the server via webservices (for example, the price of electricity at each hour in the...
1
by: BP | last post by:
Hi I have a website where i'd like to display the following times London Hong Kong New York Sydney etc
7
by: David T. Ashley | last post by:
In a web database (PHP), per user, I'd like to allow each user to specify their timezone (this would change how times are adjusted for display for that user). How do I enumerate all possible...
27
by: Sanjay | last post by:
Hi All, I am using pytz.common_timezones to populate the timezone combo box of some user registration form. But as it has so many timezones (around 400), it is a bit confusing to the users. Is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.