Time Zone

link - http://www.cpearson.com/excel/TimeZoneAndDaylightTime.aspx

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(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
    
Private Enum TIME_ZONE

    TIME_ZONE_ID_INVALID = 0 ' Cannot determine DST
    TIME_ZONE_STANDARD = 1 ' Standard Time, not Daylight
    TIME_ZONE_DAYLIGHT = 2 ' Daylight Time, not Standard

End Enum

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

Private Declare Sub GetSystemTime Lib "kernel32" _
    (lpSystemTime As SYSTEMTIME)

Function IntArrayToString(V As Variant) As String

    Dim N As Long
    Dim S As String
    For N = LBound(V) To UBound(V)
        S = S & Chr(V(N))
    Next N
    IntArrayToString = S

End Function

Sub Testing()

    Dim TZI As TIME_ZONE_INFORMATION
    Dim DST As TIME_ZONE
    Dim StandardName As String
    
    DST = GetTimeZoneInformation(TZI)
    StandardName = IntArrayToString(TZI.StandardName)
    Debug.Print StandardName

End Sub

© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext