Re: Finding the offset of a specific time zone

Aurel Velicanu <[email protected]> Wed, 25 Mar 2009 09:37:02 -0700
Newsgroups gmane.comp.windows.devel.dotnet.advanced
Message-ID <[email protected]>
If you work with .net 2.0 you have DateTime.UtcNow that I would use to eliminate location troubles. You can convert to local on the client side where you have the accurate info about day time saving.  being in US it may not be a real issue but for other converions this may be a serious headaches. 
 
The libraries on the server should give you the right DateTime.UtcNow.
 
 
Aurel Velicanu
--- On Wed, 3/25/09, Eddie Lascu <[email protected]> wrote:


From: Eddie Lascu <[email protected]>
Subject: [ADVANCED-DOTNET] Finding the offset of a specific time zone
To: [email protected]
Date: Wednesday, March 25, 2009, 12:11 PM


Hello folks,

Here is a problem I am facing right now. I work on an application that will
be hosted on some servers located in Florida. The application collects data
from some field devices located in California. The field devices contain a
time stamp that represents the date and time when the device was last time
updated. This, obviously, comes as Pacific local time. Every time a record
related to the actual device is updated in the database, the application
must update a date&time field. Since the application runs in Florida, this
will be Eastern local time.

I need to somehow be able to save these times in relation to UTC. The
database is Oracle and it has two components, a date and time and an offset
to the UTC. My question is whether I can somehow figure out programmatically
what is the offset to UTC for various time zones.

For the server where the application runs I can do something like this:

DateTime dtNow = DateTime.Now;
DateTime dtUtcNow = dtNow.ToUniversalTime();
double dOffset = (dtUtcNow - dtNow).TotalHours;

The question is how can I find out the offset of the time stamp that comes
from the field device. Is there any method in .Net that will give me that?

.NET 3.5 has TimeZoneInfo, a class that seems to solve this very issue, but
we are using a .NET 3.0 environment and TimeZoneInfo is not available. Does
anyone has any idea how this can be achieved in .NET 3.0?
Any suggestion will be highly appreciated.

Regards,
Eddie

===================================
View archives and manage your subscription(s) at http://peach.ease.lsoft.com/archives



      

===================================
View archives and manage your subscription(s) at http://peach.ease.lsoft.com/archives