Re: Finding the offset of a specific time zone
Eddie Lascu <[email protected]> Wed, 25 Mar 2009 12:41:05 -0400
| Newsgroups | gmane.comp.windows.devel.dotnet.advanced |
|---|---|
| Organization | IBI Group |
| Message-ID | <[email protected]> |
Hi Peter, That is exactly what I am trying to do, save the dates as UTC. The strings that I get are local time stamps and the offset is not provided, so I need to figure it out myself and then add it when I create the equivalent UTC value. How do I get the offset? Sorry if my explanations were clear as mud. Regards, Eddie -----Original Message----- From: Discussion of advanced .NET topics. [mailto:[email protected]] On Behalf Of Peter Ritchie Sent: Wednesday, March 25, 2009 12:31 PM To: [email protected] Subject: Re: [ADVANCED-DOTNET] Finding the offset of a specific time zone You're approaching this from the wrong direction. The only way to solve this issue is for the applications to only send UTC/GMT dates to the server. The server doesn't know where dates came from, only that they are dates. Unless these dates are UTC/GMT there's no way to convert the date to a particular locale. Whatever reads the date from the database would read the UTC/GMT date and convert that to whatever local date/time it needs to display it in. Remember that a "time zone time offset" is dependant on the date/time in which is required. In Estern dates in daylight savings time the offset will be -5, in standard time the offset will be -4. i.e. the offset depends on what the date/time is. -- Peter On Wed, 25 Mar 2009 12:11:18 -0400, Eddie Lascu <[email protected]> wrote: >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 =================================== View archives and manage your subscription(s) at http://peach.ease.lsoft.com/archives