PDA

View Full Version : Solved: daylight savings time



av8tordude
06-30-2010, 10:18 AM
I have a checkbox in a userform that I check to update the time whenever daylight savings time is in effect. Is it possible for this checkbox to automatically get checked when daylight savings time on the computer is in effect?

Bob Phillips
06-30-2010, 10:35 AM
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

Public Enum TIME_TYPE
INDETERMINATE_TIME = 0 ' Cannot determine DST
STANDARD_TIME = 1 ' Standard Time, not Daylight
DAYLIGHT_SAVINGS_TIME = 2 ' Daylight Time, not Standard
End Enum

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

Function DaylightMode() As TIME_TYPE
Dim TZI As TIME_ZONE_INFORMATION
Dim DST As TIME_TYPE
DST = GetTimeZoneInformation(TZI)
DaylightMode = DST
End Function

Sub TestDST()
MsgBox DaylightMode = DAYLIGHT_SAVINGS_TIME
End Sub

av8tordude
07-03-2010, 05:31 AM
sorry for the late reply. Thank you XLD. The code works great.