Function Reference


_Date_Time_SetTimeZoneInformation

Sets the current time zone settings

#include <Date.au3>
_Date_Time_SetTimeZoneInformation ( $iBias, $sStdName, $tStdDate, $iStdBias, $sDayName, $tDayDate, $iDayBias )

Parameters

$iBias 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
$sStdName The description for standard time
$tStdDate A $tagSYSTEMTIME structure that contains a date and local time when the transition from daylight saving time to standard time occurs.
$iStdBias 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.
$sDayName The description for daylight saving time
$tDayDate A $tagSYSTEMTIME structure that contains a date and local time when the transition from standard time to daylight saving time occurs.
$iDayBias The bias value to be used during local time translation 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.

Return Value

Success: True
Failure: False

Remarks

To select the correct day in the month, set the wYear member to zero, the wHour and wMinute members to the transition time, the wDayOfWeek member to the appropriate weekday, and the wDay member to indicate 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_GetTimeZoneInformation

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