Re: DateTime and timezone.
From: Jerry Pisk (jerryiii_at_hotmail.com)
Date: 05/30/04
- Next message: Jon Skeet [C# MVP]: "Re: All Your Thread Are Belong to Us"
- Previous message: Jerry Pisk: "Re: All Your Thread Are Belong to Us"
- In reply to: Kevin Burton: "Re: DateTime and timezone."
- Next in thread: Kevin Burton: "Re: DateTime and timezone."
- Messages sorted by: [ date ] [ thread ]
Date: Sun, 30 May 2004 00:59:03 -0700
Are you sure you're using "Mountain Standard Time" and not "US Mountain
Standard Time"? The difference between those two is that "US Mountain
Standard Time" is used in Arizona (except Navajo Nation) and doesn't observe
daylight saving time. That would explain the difference you're seeing (and
show that your code works fine :)
Jerry
"Kevin Burton" <rkevinburton@charter.net> wrote in message
news:Ox7RpJZREHA.3616@TK2MSFTNGP11.phx.gbl...
> The sequence that I am using:
>
> GetTimeZoneInformation - This returns the TIME_ZONE_INFORMATION for the
> current compter. I am in the central time zone so I see a bias of 360
> minutes (6 hours) with a daylight savings time bias of -60 (-1 hour).
> GetSystemTime - This returns the UTC current time it show a time that is 5
> hours ahead of the current time.
> Read TIME_ZONE_INFORMATION from registry - For my test I am using
"Mountain
> Standard Time" which shows a bias of 420 minutes and 0 daylight savings
> bias.
> SystemTimeToTzSpecificLocalTime - I pass the system time that I received
> from GetSystemTime and the TIME_ZONE_INFORMATION that I read from the
> registry. With no errors this functions tells me that it is 2 hours
earlier
> in the mountain time zone as opposed to the 1 hour that I was suspecting.
I
> must be calling these wrong and/or there is something with daylight
savings
> time that I am not taking into account.
>
> Thank you for your help. I will look for the P/Invoke sample.
>
> Kevin
>
>
> "Jerry Pisk" <jerryiii@hotmail.com> wrote in message
> news:OMoHlROREHA.2976@TK2MSFTNGP10.phx.gbl...
> > You should get the daylight savings time if it's in effect. I don't know
> why
> > you're getting time that's an hour off. If the original system time
> correct
> > in UTC?
> >
> > Btw there is a class to do this using P/Invoke, it's on gotdotnet I
think,
> I
> > guess I should've said that earlier...
> >
> > Jerry
> >
> > "Kevin Burton" <anonymous@discussions.microsoft.com> wrote in message
> > news:D4D66325-4521-4446-B81B-D52FB603676B@microsoft.com...
> > > You have been very helpful. I am well on my way to a good support
class.
> I
> > have chosen to use managed C++ rather than P/Invoke. It is just easier
for
> > me.
> > >
> > > One more question. The registry has entries for the standard time
zones
> > and there is a TIME_ZONE_INFORMATION struction associated with each of
the
> > standard time zones. However, if I want to get the local time in the
> > Mountain Standard Time zone (I am in Central Time Zone) I do a
> > GetSystemTime() then SystemTimeToTzSpecificLocalTime using the key value
> > from the "Mountain Standard Time" for the TIME_ZONE_INFORMATION. If I
> > calculate the difference between the current time, in CT, and MT it
comes
> > out to be 2 hours instead of 1 hour like I would expect. I am guessing
> that
> > since I passed "Mountain Standard Time" the TIME_ZONE_INFORMATION
> structure
> > that is returned is for "Mountain Standard Time" and not "Mountain
> Daylight
> > Savings Time". I see that in the structure that there are bias' for
> daylight
> > savings time and standard time. How do I detect that daylight savings
time
> > is in effect?
> > >
> > > Thanks again.
> > >
> > > Kevin
> >
> >
>
>
- Next message: Jon Skeet [C# MVP]: "Re: All Your Thread Are Belong to Us"
- Previous message: Jerry Pisk: "Re: All Your Thread Are Belong to Us"
- In reply to: Kevin Burton: "Re: DateTime and timezone."
- Next in thread: Kevin Burton: "Re: DateTime and timezone."
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|