Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / Win API / October 2003



Tip: Looking for answers? Try searching our database.

GetTimeZoneInformation madness !

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Xylos - 29 Oct 2003 20:55 GMT
Hello group
I ve browsed a lot of Google resources ans MSDN reference for GetTimeZoneInformation
but i still have not a clue about the values i am getting for StandardDate and DaylightDate.
thank you in advance for any help or information. i may be missing something obvious.

I get for StandardDate:

wDay = 3
wDayOfWeek = 5
wHour = 0
wMilliseconds = 0
wMinute = 0
wMonth = 0
wSecond = 0
wYear = 10

I get for DayLightDate:

wDay = 0
wDayOfWeek = 0
wHour = 0
wMilliseconds = 0
wMinute = -60
wMonth = 2
wSecond = -1
wYear = 5

And here is my code :

Private Declare Function GetTimeZoneInformation Lib "kernel32" _
(lpTimeZoneInformation As TIME_ZONE_INFORMATION) As Long

Private Type SYSTEMTIME
   wYear As Integer
   wMonth As Integer
   wDayOfWeek As Integer
   wDay As Integer
   wHour As Integer
   wMinute As Integer
   wSecond As Integer
   wMilliseconds As Integer

End Type

Private Type TIME_ZONE_INFORMATION
   Bias As Long
   StandardName(32) As Integer
   StandardDate As SYSTEMTIME
   StandardBias As Long
   DaylightName(32) As Integer
   DaylightDate As SYSTEMTIME
   DaylightBias As Long

End Type
Private Sub Form_Load()

Dim st As SYSTEMTIME
Dim tzi As TIME_ZONE_INFORMATION
Dim ret As Long

ret = GetTimeZoneInformation(tzi)
st = tzi.StandardDate

MsgBox st.wDay
MsgBox st.wDayOfWeek
MsgBox st.wHour
MsgBox st.wMilliseconds
MsgBox st.wMinute
MsgBox st.wMonth
MsgBox st.wSecond
MsgBox st.wYear

st = tzi.DaylightDate

MsgBox st.wDay
MsgBox st.wDayOfWeek
MsgBox st.wHour
MsgBox st.wMilliseconds
MsgBox st.wMinute
MsgBox st.wMonth
MsgBox st.wSecond
MsgBox st.wYear

End Sub
alpine - 29 Oct 2003 21:10 GMT
Have you looked at the GetTimezoneInfo demo at
http://www.mvps.org/vbvision/  ?

HTH,
Bryan
____________________________________________________________
New Vision Software                   "When the going gets weird,"
Bryan Stafford                     "the weird turn pro."
alpine_don'tsendspam@mvps.org     Hunter S. Thompson -  
Microsoft MVP-Visual Basic     Fear and Loathing in LasVegas

>Hello group
>I ve browsed a lot of Google resources ans MSDN reference for GetTimeZoneInformation
[quoted text clipped - 80 lines]
>
>End Sub
Xylos - 29 Oct 2003 21:25 GMT
Well thank you, it solved my problem !!

in fact the type declaration from Api Viewer 2002 TIME_ZONE_INFORMATION is creating the problem

<-BAD->

Private Type TIME_ZONE_INFORMATION
Bias As Long
StandardName(32) As Integer
StandardDate As SYSTEMTIME
StandardBias As Long
DaylightName(32) As Integer
DaylightDate As SYSTEMTIME
DaylightBias As Long
End Type

<-GOOD ->

 Private Type TIME_ZONE_INFORMATION
   Bias As Long
   StandardName(63) As Byte  ' <-- zero based array so there are actually 64 bytes in the array
   StandardDate As SYSTEMTIME
   StandardBias As Long
   DaylightName(63) As Byte  ' <-- zero based array so there are actually 64 bytes in the array
   DaylightDate As SYSTEMTIME
   DaylightBias As Long
 End Type

> Have you looked at the GetTimezoneInfo demo at
> http://www.mvps.org/vbvision/  ?
[quoted text clipped - 91 lines]
> >
> >End Sub
Mike D Sutton - 30 Oct 2003 00:27 GMT
> Well thank you, it solved my problem !!
>
> in fact the type declaration from Api Viewer 2002
> TIME_ZONE_INFORMATION is creating the problem

You could also most likely use this version:

'***
Private Type TIME_ZONE_INFORMATION
   Bias As Long
   StandardName(31) As Integer
   StandardDate As SYSTEMTIME
   StandardBias As Long
   DaylightName(31) As Integer
   DaylightDate As SYSTEMTIME
   DaylightBias As Long
End Type
'***

However the byte versions is easier to use with VB since you can simply typecast the byte array to a string.
Hope this helps,

   Mike

- Microsoft Visual Basic MVP -
E-Mail: EDais@mvps.org
WWW: Http://www.mvps.org/EDais/
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.