Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Daylight Savings Time - Looking for Chip H.

Status
Not open for further replies.

dionu

Programmer
Oct 19, 2001
10
CA
Chip,

I have questions regarding some help you posted about a year ago in regards to a Daylight Savings Time question. The GetTimeZoneInformation function to be specific. How do you properly call that function. It seems like you need to provide an arguement, but I thought the arguement is what you were looking for?

 
OK, if you refer to the other thread (thread222-77535), you'll see that I'm defining a Type named TIME_ZONE_INFORMATION. You need to declare a variable of this type like:
Code:
Dim MyTimeZoneInfo as TIME_ZONE_INFORMATION
You then call the GetTimeZoneInformation function like this:
Code:
Dim lRC As Long

lRC = GetTimeZoneInformation(MyTimeZoneInfo)
If lRC is a 0, the system doesn't know if you're in DST or not. If it's a 1, you're in Standard Time. If it's a 2, then you're in DST.

If it's a 0, you can examine the contents of the MyTimeZoneInfo Type to maybe make a further decision. You'll have to copy the SYSTEMTIME elements to a Date variable by hand:
Code:
Dim dtStandardBegins as Date
Dim dtSavingsBegins as Date

dtStandardBegins = DateSerial(MyTimeZoneInfo.StandardDate.wYear, _
    MyTimeZoneInfo.StandardDate.wMonth, _
    MyTimeZoneInfo.StandardDate.wDay)
dtSavingsBegins = DateSerial(MyTimeZoneInfo.DaylightDate.wYear, _
    MyTimeZoneInfo.DaylightDate.wMonth, _
    MyTimeZoneInfo.DaylightDate.wDay)
The DaylightBias and StandardBias elements of the TIME_ZONE_INFORMATION Type tells you how far the clock changes on those dates (negative value means you lose time). Like I said in the other thread, you can use the DateDiff function against one of these and the contents of the Now() function to tell if you're in DST or not.

Hope this helps.

Chip H.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top