Function Reference


_Date_Time_GetTimeZoneInformation

Retrieves the current time zone settings

#include <Date.au3>
_Date_Time_GetTimeZoneInformation ( )

Return Value

Success: Returns an array with the following format:
    [0] - Daylight savings setting. Can be one of the following:
        -1 - Failure
         0 - Daylight savings time is not used in the current time zone
         1 - Daylight savings time operating with standard time
         2 - Daylight savings time operating with daylight savings time
    [1] - The current bias for local time translation on this computer.
        The bias is the difference in minutes between Coordinated Universal Time (UTC) and local time.
        All translations between UTC and local time use the following formula: UTC = local time + bias
    [2] - The description for standard time
    [3] - A $tagSYSTEMTIME structure that contains a date and local time when the transition from daylight saving time to standard time occurs.
    [4] - The bias value to be used during local time translations that occur during standard time.
        This value is added to the value of the Bias to form the bias used during standard time.
        In most time zones, this value is zero.
    [5] - The description for daylight saving time
    [6] - A $tagSYSTEMTIME structure that contains a date and local time when the transition from standard time to daylight saving time occurs.
    [7] - The bias value to be used during local time translations that occur during daylight saving time.
        This value is added to the value of the Bias member to form the bias used during daylight saving time. In most time zones this value is –60.
Failure: Sets the @error flag to non-zero.

Remarks

In the $tagSYSTEMTIME structure, the wHour and wMinute members represent the transition time, the wDayOfWeek member to the appropriate weekday, and the wDay member indicating the occurrence of the day of the week within the month (1 to 5, where 5 indicates the final occurrence during the month if that day of the week does not occur 5 times).

Using this notation, specify 02:00 on the first Sunday in April as follows: wHour = 2, wMonth = 4, wDayOfWeek = 0, wDay = 1. Specify 02:00 on the last Thursday in October as follows: wHour = 2, wMonth = 10, wDayOfWeek = 4, wDay = 5.

Related

$tagSYSTEMTIME, _Date_Time_SetTimeZoneInformation

Example

;~ #RequireAdmin
; the Windows API "SetTimeZoneInformation" need "SeTimeZonePrivilege" so you have to use #RequireAdmin

#include <Date.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIError.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
        ; Create GUI
        GUICreate("Date_Time Get/Set Time ZoneInformation (v" & @AutoItVersion & ")", 460, 460)
        $g_idMemo = GUICtrlCreateEdit("", 2, 2, 456, 456, $WS_VSCROLL)
        GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
        GUISetState(@SW_SHOW)

        ; Show current time zone information
        Local $aOld = _Date_Time_GetTimeZoneInformation()
        ShowTimeZoneInformation($aOld, "Current")

        ; Set new time zone information , just name's updates
        If Not _Date_Time_SetTimeZoneInformation($aOld[1], "A3L CST", $aOld[3], $aOld[4], "A3L CDT", $aOld[6], $aOld[7]) Then
                MsgBox($MB_SYSTEMMODAL, "Error", "System timezone cannot be SET @error=" & @error & @CRLF & @CRLF & _WinAPI_GetErrorMessage(@extended))
                Exit
        EndIf

        ; Show new time zone information
        Local $aNew = _Date_Time_GetTimeZoneInformation()
        ShowTimeZoneInformation($aNew, "New")

        ; Reset original time zone information
        _Date_Time_SetTimeZoneInformation($aOld[1], $aOld[2], $aOld[3], $aOld[4], $aOld[5], $aOld[6], $aOld[7])

        ; Show current time zone information
        $aOld = _Date_Time_GetTimeZoneInformation()
        ShowTimeZoneInformation($aOld, "Reset")

        ; Loop until the user exits.
        Do
        Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
        GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

; Show time zone information
Func ShowTimeZoneInformation(ByRef $aInfo, $sComment)
        MemoWrite("******************* " & $sComment & " *******************")
        MemoWrite("Result ............: " & $aInfo[0])
        MemoWrite("Current bias ......: " & $aInfo[1])
        MemoWrite("Standard name .....: " & $aInfo[2])
        MemoWrite("Standard date/time : " & _Date_Time_SystemTimeToDateTimeStr($aInfo[3]))
        MemoWrite("Standard bias......: " & $aInfo[4])
        MemoWrite("Daylight name .....: " & $aInfo[5])
        MemoWrite("Daylight date/time : " & _Date_Time_SystemTimeToDateTimeStr($aInfo[6]))
        MemoWrite("Daylight bias......: " & $aInfo[7])
EndFunc   ;==>ShowTimeZoneInformation