Jump to content

The offset from GMT-UTC in standard format


masvil
 Share

Recommended Posts

The script shows the offset from GMT-UTC in standard format through string manipulation.

#include <Date.au3>

ConsoleWrite (_TimeZoneInfo() & @CRLF)

Func _TimeZoneInfo()
    $aInfo = _Date_Time_GetTimeZoneInformation()
    ConsoleWrite("bias: " & $aInfo[1] & @CRLF)
    $hours = $aInfo[1] / 60
    If $hours = "0" Then
        $hours = "+00:00"
    Else
        If StringInStr($hours, "-") Then
            $hours = StringReplace($hours, "-", "+")
        Else
            $hours = "-" & $hours
        EndIf
        If Not StringInStr($hours, ".") Then $hours = $hours & ":00"
        $hours = StringReplace($hours, ".5", ":30")
        $hours = StringReplace($hours, ".75", ":45")
        If StringLen($hours) = 5 Then $hours = StringLeft($hours, 1) & "0" & StringRight($hours, 4)
    EndIf
    Return ($aInfo[2] & " (GMT" & $hours & ")")
EndFunc   ;==>_TimeZoneInfo

 

Edited by masvil
improving
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...