Jump to content

Recommended Posts

Posted (edited)

Times are obtained from the server at worldtimeapi.org.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile=TimeIn.exe
#AutoIt3Wrapper_UseUpx=y
#AutoIt3Wrapper_UseX64=n
#AutoIt3Wrapper_Run_Au3Stripper=y
#AutoIt3Wrapper_AU3Check_Parameters=-w 3 -w 4 -w 5 -w 6 -d
#AutoIt3Wrapper_Change2CUI=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
;
#include <Date.au3>
; World Time via API at worldtimeapi.org
Global $sRevDate = "[CLD rev. 2024-12-21]"
;
If $CmdLine[0] = 0 Then Exit _ShowHelp()
If StringInStr($CmdLine[1], "?") Then Exit _ShowHelp()

Global $aData, $aDow, $aDTm, $aFrac = "", $aSubst, $aTZdata
Global $bPossDST = 0, $DTadj, $DTime, $h1, $h2
Global $iDoW, $iIncr = 0, $iMatch
Global $sData = "", $sDataFn = @ScriptDir & "\timedat.dat"
Global $sOut = "", $sSubst, $iTmp
Global $sTail = "", $sTZdata, $sWhere = ""
Global $sURL = "http://worldtimeapi.org/api/timezone/"

If $CmdLine[0] Then $sWhere = $CmdLineRaw
If StringInStr($sWhere, " ") Then $sWhere = StringReplace($sWhere, " ", "_")
If StringInStr($sWhere, ".") Then $sWhere = StringReplace($sWhere, ".", "")
If StringInStr($sWhere, "UTC+") Then $sWhere = StringReplace($sWhere, "UTC+", "GMT+")
If StringInStr($sWhere, "UTC-") Then $sWhere = StringReplace($sWhere, "UTC-", "GMT-")
If StringInStr($sWhere, "GMT+") Then $sWhere = StringReplace($sWhere, "GMT+", "GMT-")
If StringInStr($sWhere, "GMT-") Then $sWhere = StringReplace($sWhere, "GMT-", "GMT+")

; Substitution table
; GMT offsets use opposite sign -/+ (quirk of WorldTimeAPI data format)
$sSubst = "EST5EDT,Washington,Washington_DC,DC,Miami,Atlanta,Boston,Philadelphia,|CST6CDT,New_Orleans,Minneapolis,Kansas_City,Oklahoma_City,Dallas,Houston,|MST7MDT,Salt_Lake_City,|PST8PDT,San_Diego,San_Francisco,Las_Vegas,Seattle,|GMT,Reykjavik,Douglas,Bamako,Timbuktu,Nouakchott,Jamestown,Dakar,Freetown,Lomé,Greenwich,Edinburgh,Cardiff,Suva,Majuro,Yaren,Pevek,Petropavlovsk-Kamchatsky,Ouagadougou,Funafuti,Wake_Island,Yamoussoukro,Torshavn,Tórshavn,Banjul,Accra,Conakry,|GMT-1,Tirana,Luanda,Porto_Novo,Sarajevo,Yaounde,Yaoundé,Bangui,N'Djamena,Brazzaville,Kinshasa,Zagreb,Copenhagen,Malabo,Libreville,Frankfurt,Luxembourg,Vaduz,Valletta,Monaco,Podgorica,Casablanca*,Rabat*,Amsterdam,Niamey,Abuja,Skopje,Longyearbyen,Oslo,Tromso,Bratislava,Ljubljana,Barcelona,Stockholm,Bern,Zurich,Zürich,Vatican_City,El_Aaiun*,El_Aaiún*,|GMT-2,Tel_Aviv,Gaborone,Benghazi,Bujumbura,Gitega,Lubumbashi,Mbabane,Kemi,Rovaniemi,Maseru,Lilongwe,Kigali,Cape_Town,Pretoria,Dnipro,Lusaka,Harare,|GMT-3,Dar_es_Salaam,|GMT-4,Port_Louis,Muscat,Saint-Denis,Izhevsk,Seychelles,Victoria,Abu_Dhabi,|GMT-5,Port-aux-Francais,Amsterdam_Island,Astana,Male,Islamabad,Lahore,|GMT-5:30,New_Delhi,Bengaluru,Mumbai,Bombay,Chennai,Kolkata,Calcutta,Sri_Jayawardenepura_Kotte,|GMT-5:45,Kathmandu,|GMT-6,Diego_Garcia,|GMT-6:30,Naypyidaw,|GMT-6:30,Yangon,|GMT-7,Phnom_Penh,Vientiane,Khatanga,Norilsk,Hanoi,|GMT-8,Bandar_Seri_Begawan,Beijing,Chongqing,Lhasa,Urumqi,Ürümqi,Denpasar,Nusantara,Kuala_Lumpur,|GMT-8:45,Eucla,|GMT-9,Manokwari,Ngerulmud,Tiksi,|GMT-9:30,Alice_Springs,Darwin,|GMT-10,Cairns,Hagatna,Hagåtña,Komsomolsk-on-Amur,Verkhoyansk,|GMT-10:30,Adelaide*,|GMT-11,Canberra*,Sydney*,Hobart*,Melbourne*,Palikir,Yuzhno-Sakhalinsk,Honiara,Port_Vila,|GMT-12,Wake_Island,|GMT+1,Praia,Ponta_Delgada,|GMT+2,Ittoqqortoormiit,Kangerlussuaq,Qaanaaq,King_Edward_Point,|GMT+3,Cordoba,Córdoba,Brasilia,Belem,Belém,Rio_de_Janeiro,Punta_Arenas*,Santiago*,|GMT+3:30,Mary's_Harbour,St_John's,St_Johns,|GMT+4,Bridgetown,Hamilton,Sucre,Happy_Valley-Thule_Air_Base,Basse-Terre,Georgetown,Port_of_Spain,|GMT+5,Nassau,Alert,Coral_Harbour,Eureka,Grise_Fiord,Pond_Inlet,Ottawa,Chibougamau,Kuujjuaq,Montreal,Montréal,Easter_Island*,Quito,Kingston,Cancun,Cancún,|GMT+6,Belmopan,Baker_Lake,Resolute_Bay,San_Jose,Galapagos_Islands,San_Salvador,Guatemala_City,|GMT+7,Calgary,|GMT+8,Adamstown,|GMT+9,Fairbanks,Unalaska,|GMT+10,Papeete,|GMT+11,Dodoma,Alofi,Ankara,Midway,Kampala,Sana,Manama,Moroni,Djibouti,Asmara,Addis_Ababa,Kuwait_City,Antananarivo,Doha,Belushya_Guba,Mogadishu,Marion_Island_(Prince_Edward_Islands),Marion_Island,|GMT+12,Baker_Island,"

$aSubst = StringSplit($sSubst, "|")
For $i = 1 To $aSubst[0]
    If StringInStr($aSubst[$i], ("," & $sWhere)) Then
        If StringInStr($aSubst[$i], ("," & $sWhere & "*")) Then
            $sWhere &= "*"
            $bPossDST = 1
        EndIf
        If StringInStr($aSubst[$i], ("," & $sWhere & ",")) Then $sWhere = _
            StringLeft($aSubst[$i], StringInStr($aSubst[$i], ",") - 1)
        If StringInStr($sWhere, "GMT") = 1 Then $sWhere = "Etc/" & $sWhere
    EndIf
Next

; Fractional UTC/GMT offsets
If StringInStr($sWhere, ":") Then
    $aFrac = StringSplit($sWhere, ":")
    $sWhere = $aFrac[1]
    $iIncr = $aFrac[2]
    If StringInStr($sWhere, "+") Then $iIncr *= -1
EndIf

$sTZdata = "Africa/Abidjan,Africa/Algiers,Africa/Bissau,Africa/Cairo,Africa/Casablanca,Africa/Ceuta,Africa/El_Aaiun,Africa/Johannesburg,Africa/Juba,Africa/Khartoum,Africa/Lagos,Africa/Maputo,Africa/Monrovia,Africa/Nairobi,Africa/Ndjamena,Africa/Sao_Tome,Africa/Tripoli,Africa/Tunis,Africa/Windhoek,America/Adak,America/Anchorage,America/Araguaina,America/Argentina/Buenos_Aires,America/Argentina/Catamarca,America/Argentina/Cordoba,America/Argentina/Jujuy,America/Argentina/La_Rioja,America/Argentina/Mendoza,America/Argentina/Rio_Gallegos,America/Argentina/Salta,America/Argentina/San_Juan,America/Argentina/San_Luis,America/Argentina/Tucuman,America/Argentina/Ushuaia,America/Asuncion,America/Bahia,America/Bahia_Banderas,America/Barbados,America/Belem,America/Belize,America/Boa_Vista,America/Bogota,America/Boise,America/Cambridge_Bay,America/Campo_Grande,America/Cancun,America/Caracas,America/Cayenne,America/Chicago,America/Chihuahua,America/Ciudad_Juarez,America/Costa_Rica,America/Cuiaba,America/Danmarkshavn,America/Dawson,America/Dawson_Creek,America/Denver,America/Detroit,America/Edmonton,America/Eirunepe,America/El_Salvador,America/Fort_Nelson,America/Fortaleza,America/Glace_Bay,America/Goose_Bay,America/Grand_Turk,America/Guatemala,America/Guayaquil,America/Guyana,America/Halifax,America/Havana,America/Hermosillo,America/Indiana/Indianapolis,America/Indiana/Knox,America/Indiana/Marengo,America/Indiana/Petersburg,America/Indiana/Tell_City,America/Indiana/Vevay,America/Indiana/Vincennes,America/Indiana/Winamac,America/Inuvik,America/Iqaluit,America/Jamaica,America/Juneau,America/Kentucky/Louisville,America/Kentucky/Monticello,America/La_Paz,America/Lima,America/Los_Angeles,America/Maceio,America/Managua,America/Manaus,America/Martinique,America/Matamoros,America/Mazatlan,America/Menominee,America/Merida,America/Metlakatla,America/Mexico_City,America/Miquelon,America/Moncton,America/Monterrey,America/Montevideo,America/New_York,America/Nome,America/Noronha,America/North_Dakota/Beulah,America/North_Dakota/Center,America/North_Dakota/New_Salem,America/Nuuk,America/Ojinaga,America/Panama,America/Paramaribo,America/Phoenix,America/Port-au-Prince,America/Porto_Velho,America/Puerto_Rico,America/Punta_Arenas,America/Rankin_Inlet,America/Recife,America/Regina,America/Resolute,America/Rio_Branco,America/Santarem,America/Santiago,America/Santo_Domingo,America/Sao_Paulo,America/Scoresbysund,America/Sitka,America/St_Johns,America/Swift_Current,America/Tegucigalpa,America/Thule,"

$sTZdata &= "America/Tijuana,America/Toronto,America/Vancouver,America/Whitehorse,America/Winnipeg,America/Yakutat,Antarctica/Casey,Antarctica/Davis,Antarctica/Macquarie,Antarctica/Mawson,Antarctica/Palmer,Antarctica/Rothera,Antarctica/Troll,Antarctica/Vostok,Asia/Almaty,Asia/Amman,Asia/Anadyr,Asia/Aqtau,Asia/Aqtobe,Asia/Ashgabat,Asia/Atyrau,Asia/Baghdad,Asia/Baku,Asia/Bangkok,Asia/Barnaul,Asia/Beirut,Asia/Bishkek,Asia/Chita,Asia/Choibalsan,Asia/Colombo,Asia/Damascus,Asia/Dhaka,Asia/Dili,Asia/Dubai,Asia/Dushanbe,Asia/Famagusta,Asia/Gaza,Asia/Hebron,Asia/Ho_Chi_Minh,Asia/Hong_Kong,Asia/Hovd,Asia/Irkutsk,Asia/Jakarta,Asia/Jayapura,Asia/Jerusalem,Asia/Kabul,Asia/Kamchatka,Asia/Karachi,Asia/Kathmandu,Asia/Khandyga,Asia/Kolkata,Asia/Krasnoyarsk,Asia/Kuching,Asia/Macau,Asia/Magadan,Asia/Makassar,Asia/Manila,Asia/Nicosia,Asia/Novokuznetsk,Asia/Novosibirsk,Asia/Omsk,Asia/Oral,Asia/Pontianak,Asia/Pyongyang,Asia/Qatar,Asia/Qostanay,Asia/Qyzylorda,Asia/Riyadh,Asia/Sakhalin,Asia/Samarkand,Asia/Seoul,Asia/Shanghai,Asia/Singapore,Asia/Srednekolymsk,Asia/Taipei,Asia/Tashkent,Asia/Tbilisi,Asia/Tehran,Asia/Thimphu,Asia/Tokyo,Asia/Tomsk,Asia/Ulaanbaatar,Asia/Urumqi,Asia/Ust-Nera,Asia/Vladivostok,Asia/Yakutsk,Asia/Yangon,Asia/Yekaterinburg,Asia/Yerevan,Atlantic/Azores,Atlantic/Bermuda,Atlantic/Canary,Atlantic/Cape_Verde,Atlantic/Faroe,Atlantic/Madeira,Atlantic/South_Georgia,Atlantic/Stanley,Australia/Adelaide,Australia/Brisbane,Australia/Broken_Hill,Australia/Darwin,Australia/Eucla,Australia/Hobart,Australia/Lindeman,Australia/Lord_Howe,Australia/Melbourne,Australia/Perth,Australia/Sydney,CET,CST6CDT,EET,EST,EST5EDT,Etc/GMT,Etc/GMT+1,Etc/GMT+10,Etc/GMT+11,Etc/GMT+12,Etc/GMT+2,Etc/GMT+3,Etc/GMT+4,Etc/GMT+5,Etc/GMT+6,Etc/GMT+7,Etc/GMT+8,Etc/GMT+9,Etc/GMT-1,Etc/GMT-10,Etc/GMT-11,Etc/GMT-12,Etc/GMT-13,Etc/GMT-14,Etc/GMT-2,Etc/GMT-3,Etc/GMT-4,Etc/GMT-5,Etc/GMT-6,Etc/GMT-7,Etc/GMT-8,Etc/GMT-9,Etc/UTC,Europe/Andorra,Europe/Astrakhan,Europe/Athens,Europe/Belgrade,Europe/Berlin,Europe/Brussels,Europe/Bucharest,Europe/Budapest,Europe/Chisinau,Europe/Dublin,Europe/Gibraltar,Europe/Helsinki,Europe/Istanbul,Europe/Kaliningrad,Europe/Kirov,Europe/Kyiv,Europe/Lisbon,Europe/London,Europe/Madrid,Europe/Malta,Europe/Minsk,Europe/Moscow,Europe/Paris,Europe/Prague,Europe/Riga,Europe/Rome,Europe/Samara,Europe/Saratov,Europe/Simferopol,Europe/Sofia,Europe/Tallinn,Europe/Tirane,Europe/Ulyanovsk,Europe/Vienna,Europe/Vilnius,Europe/Volgograd,Europe/Warsaw,Europe/Zurich,HST,Indian/Chagos,Indian/Maldives,Indian/Mauritius,MET,MST,MST7MDT,PST8PDT,Pacific/Apia,Pacific/Auckland,Pacific/Bougainville,Pacific/Chatham,Pacific/Easter,Pacific/Efate,Pacific/Fakaofo,Pacific/Fiji,Pacific/Galapagos,Pacific/Gambier,Pacific/Guadalcanal,Pacific/Guam,Pacific/Honolulu,Pacific/Kanton,Pacific/Kiritimati,Pacific/Kosrae,Pacific/Kwajalein,Pacific/Marquesas,Pacific/Nauru,Pacific/Niue,Pacific/Norfolk,Pacific/Noumea,Pacific/Pago_Pago,Pacific/Palau,Pacific/Pitcairn,Pacific/Port_Moresby,Pacific/Rarotonga,Pacific/Tahiti,Pacific/Tarawa,Pacific/Tongatapu,WET,"

$sSubst = StringReplace($sSubst, "_", " ")
$sSubst = StringReplace($sSubst, "*", "")
$sTZdata &= $sSubst
$aTZdata = StringSplit($sTZdata, ",")

$iMatch = _ListMatches($sWhere)
If Not $iMatch Then
    If Not $sOut Then $sOut = "Nothing on """ & $sWhere & """"
    Exit ConsoleWrite($sOut)
EndIf
$sTail = $aTZdata[$iMatch]
$sURL &= $sTail
$h1 = InetGet($sURL, $sDataFn)
If Not $h1 Then
    If Not $sOut Then
        _ExitError("Nothing on """ & $sWhere & """")
    Else
        Exit ConsoleWrite($sOut & @CRLF)
    EndIf
EndIf
InetClose($h1)
$h2 = FileOpen($sDataFn)
If $h2 < 0 Then _ExitError("Error opening " & $sDataFn)
$sData = FileRead($h2)
FileClose($h2)
If FileExists($sDataFn) Then FileDelete($sDataFn)
$aData = StringSplit($sData, ",")
$aDow = StringSplit("Mon|Tue|Wed|Thu|Fri|Sat|Sun", "|")
If $iIncr = 0 Then
    $iDoW = StringRight($aData[3], 1)
    If $iDoW < 1 Then $iDoW = 7
    $sOut &= $aDoW[$iDoW] & " "
    $sOut &= StringMid($aData[5], 24, 8)
    If $aData[10] = '"dst":true' Then $sOut &= " (DST)"
Else
    $DTime = StringReplace(StringMid($aData[5], 13, 19), "-", "/")
    $DTime = StringReplace($DTime, "T", " ")
    $DTadj = _DateAdd("n", $iIncr, $DTime)
    $aDTm = StringSplit(StringLeft($DTadj, 10), "/")
    $iDoW = _DateToDayofWeek($aDTm[1], $aDTm[2], $aDTm[3]) - 1
    If $iDoW < 1 Then $iDoW = 7
    $sOut &= $aDoW[$iDoW] & " " & StringRight($DTadj, 8)
EndIf
If $bPossDST Then $sOut &= @CRLF & "(possibly plus|minus DST offset)"
Exit ConsoleWrite($sOut & @CRLF)

Func _ListMatches($sStr = "")
    Local $iCount = 0, $iIndex = 0, $sFixGMT = "", $sStr0 = ""
    If $sStr Then
        For $i = 1 To $aTZdata[0]
            If StringInStr($aTZdata[$i], $sStr) = 0 Or _
                StringInStr($aTZdata[$i], "|") = 1 Then ContinueLoop
            $iIndex = $i
            $sStr0 = $aTZdata[$i]
            If StringInStr($sStr0, "/") And Not StringInStr($sStr0, "Etc/") Then $sStr0 = StringSplit($sStr0, "/")[2]
            If $sStr0 = $sStr Then
                $sFixGMT = $aTZdata[$i]
                If StringInStr($sFixGMT, "Etc/") = 1 Then
                    $sFixGMT = StringReplace($aTZdata[$i], "Etc/GMT", "UTC/GMT")
                    If StringInStr($sFixGMT, "+") = 8 Then
                        $sFixGMT = StringReplace($sFixGMT, "+", "-")
                    ElseIf StringInStr($sFixGMT, "-") = 8 Then
                        $sFixGMT = StringReplace($sFixGMT, "-", "+")
                    EndIf
                EndIf
                If $iIncr > 0 Then $sFixGMT &= ":" & String(Abs($iIncr))
                $sOut &= $sFixGMT & "  "
                Return $iIndex
            EndIf
            $iCount += 1
            If $iCount = 2 Then $sOut &= @CRLF
            If StringInStr($aTZdata[$i], "Etc/") = 0 Then
                $sOut &= $aTZdata[$i] & "  "
                If $iCount > 1 Then $sOut &= @CRLF
            EndIf
        Next
    EndIf
    If Not $iCount Then
        _ExitError("Nothing on """ & $sStr & """")
    Else
        If $iCount > 1 Then
            $iCount = 0
        Else
            $iCount = $iIndex
        EndIf
    EndIf
    Return $iCount
EndFunc  ;==>_ListMatches

Func _ExitError($sStr = "")
    If $sStr Then ConsoleWrite($sStr & @CRLF)
    Exit
EndFunc  ;==>_ExitError

Func _ShowHelp()
    ConsoleWrite("World Time via WorldTimeAPI " & $sRevDate & _
        @CRLF & "Supplemental time zone data from www.timeanddate.com" & _
        @CRLF & "Usage:" & @CRLF & StringTrimRight(@ScriptName, 4) & _
        " <CITY>" & @CRLF & "--" & @CRLF & StringTrimRight(@ScriptName, 4) &  _
        " <substring> lists cities in database containing <substring>" & _
        @CRLF & "Listings in format <continent>/<city> (e.g., Europe/Lisbon) obtain" & _
        @CRLF & "  the current time from the server at worldtimeapi.org." & @CRLF & _
        "Listings with city name only use an internal database to determine" & _
        @CRLF & "  the applicable UTC/GMT offset." & @CRLF & _
        "Accuracy is NOT guaranteed!" & @CRLF)
EndFunc  ;==>_ShowHelp

 

Edited by CarlD
Posted
31 minutes ago, CarlD said:

Times are obtained from the server at worldtimeapi.org.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile=F:\Dropbox\AutoIt\TimeIn.exe
#AutoIt3Wrapper_UseUpx=y
#AutoIt3Wrapper_UseX64=n
#AutoIt3Wrapper_Run_Au3Stripper=y
#AutoIt3Wrapper_AU3Check_Parameters=-w 3 -w 4 -w 5 -w 6 -d
#AutoIt3Wrapper_Change2CUI=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
;
#include <Date.au3>
; World Time via API at worldtimeapi.org
Global $sRevDate = "[CLD rev. 2024-12-21]"
;
If $CmdLine[0] = 0 Then Exit _ShowHelp()
If StringInStr($CmdLine[1], "?") Then Exit _ShowHelp()

Global $aData, $aDow, $aDTm, $aFrac = "", $aSubst, $aTZdata
Global $bPossDST = 0, $DTadj, $DTime, $h1, $h2
Global $sDoW, $iDoW0, $iDoW1, $iIncr = 0, $iMatch
Global $sData = "", $sDataFn = @ScriptDir & "\timedat.dat"
Global $sOut = "", $sSubst, $iTmp
Global $sTail = "", $sTZdata, $sWhere = ""
Global $sURL = "http://worldtimeapi.org/api/timezone/"

If $CmdLine[0] Then $sWhere = $CmdLineRaw
If StringInStr($sWhere, " ") Then $sWhere = StringReplace($sWhere, " ", "_")
If StringInStr($sWhere, ".") Then $sWhere = StringReplace($sWhere, ".", "")
If StringInStr($sWhere, "UTC+") Then $sWhere = StringReplace($sWhere, "UTC+", "GMT+")
If StringInStr($sWhere, "UTC-") Then $sWhere = StringReplace($sWhere, "UTC-", "GMT-")
If StringInStr($sWhere, "GMT+") Then $sWhere = StringReplace($sWhere, "GMT+", "GMT-")
If StringInStr($sWhere, "GMT-") Then $sWhere = StringReplace($sWhere, "GMT-", "GMT+")

; Substitution table
; GMT offsets use opposite sign -/+ (quirk of WorldTimeAPI data format)
$sSubst = "EST5EDT,Washington,Washington_DC,DC,Miami,Atlanta,Boston,Philadelphia,|CST6CDT,New_Orleans,Minneapolis,Kansas_City,Oklahoma_City,Dallas,Houston,|MST7MDT,Salt_Lake_City,|PST8PDT,San_Diego,San_Francisco,Las_Vegas,Seattle,|GMT,Reykjavik,Douglas,Bamako,Timbuktu,Nouakchott,Jamestown,Dakar,Freetown,Lomé,Greenwich,Edinburgh,Cardiff,Suva,Majuro,Yaren,Pevek,Petropavlovsk-Kamchatsky,Ouagadougou,Funafuti,Wake_Island,Yamoussoukro,Torshavn,Tórshavn,Banjul,Accra,Conakry,|GMT-1,Tirana,Luanda,Porto_Novo,Sarajevo,Yaounde,Yaoundé,Bangui,N'Djamena,Brazzaville,Kinshasa,Zagreb,Copenhagen,Malabo,Libreville,Frankfurt,Luxembourg,Vaduz,Valletta,Monaco,Podgorica,Casablanca*,Rabat*,Amsterdam,Niamey,Abuja,Skopje,Longyearbyen,Oslo,Tromso,Bratislava,Ljubljana,Barcelona,Stockholm,Bern,Zurich,Zürich,Vatican_City,El_Aaiun*,El_Aaiún*,|GMT-2,Tel_Aviv,Gaborone,Benghazi,Bujumbura,Gitega,Lubumbashi,Mbabane,Kemi,Rovaniemi,Maseru,Lilongwe,Kigali,Cape_Town,Pretoria,Dnipro,Lusaka,Harare,|GMT-3,Dar_es_Salaam,|GMT-4,Port_Louis,Muscat,Saint-Denis,Izhevsk,Seychelles,Victoria,Abu_Dhabi,|GMT-5,Port-aux-Francais,Amsterdam_Island,Astana,Male,Islamabad,Lahore,|GMT-5:30,New_Delhi,Bengaluru,Mumbai,Bombay,Chennai,Kolkata,Calcutta,Sri_Jayawardenepura_Kotte,|GMT-5:45,Kathmandu,|GMT-6,Diego_Garcia,|GMT-6:30,Naypyidaw,|GMT-6:30,Yangon,|GMT-7,Phnom_Penh,Vientiane,Khatanga,Norilsk,Hanoi,|GMT-8,Bandar_Seri_Begawan,Beijing,Chongqing,Lhasa,Urumqi,Ürümqi,Denpasar,Nusantara,Kuala_Lumpur,|GMT-8:45,Eucla,|GMT-9,Manokwari,Ngerulmud,Tiksi,|GMT-9:30,Alice_Springs,Darwin,|GMT-10,Cairns,Hagatna,Hagåtña,Komsomolsk-on-Amur,Verkhoyansk,|GMT-10:30,Adelaide*,|GMT-11,Canberra*,Sydney*,Hobart*,Melbourne*,Palikir,Yuzhno-Sakhalinsk,Honiara,Port_Vila,|GMT-12,Wake_Island,|GMT+1,Praia,Ponta_Delgada,|GMT+2,Ittoqqortoormiit,Kangerlussuaq,Qaanaaq,King_Edward_Point,|GMT+3,Cordoba,Córdoba,Brasilia,Belem,Belém,Rio_de_Janeiro,Punta_Arenas*,Santiago*,|GMT+3:30,Mary's_Harbour,St_John's,St_Johns,|GMT+4,Bridgetown,Hamilton,Sucre,Happy_Valley-Thule_Air_Base,Basse-Terre,Georgetown,Port_of_Spain,|GMT+5,Nassau,Alert,Coral_Harbour,Eureka,Grise_Fiord,Pond_Inlet,Ottawa,Chibougamau,Kuujjuaq,Montreal,Montréal,Easter_Island*,Quito,Kingston,Cancun,Cancún,|GMT+6,Belmopan,Baker_Lake,Resolute_Bay,San_Jose,Galapagos_Islands,San_Salvador,Guatemala_City,|GMT+7,Calgary,|GMT+8,Adamstown,|GMT+9,Fairbanks,Unalaska,|GMT+10,Papeete,|GMT+11,Dodoma,Alofi,Ankara,Midway,Kampala,Sana,Manama,Moroni,Djibouti,Asmara,Addis_Ababa,Kuwait_City,Antananarivo,Doha,Belushya_Guba,Mogadishu,Marion_Island_(Prince_Edward_Islands),Marion_Island,|GMT+12,Baker_Island,"

$aSubst = StringSplit($sSubst, "|")
For $i = 1 To $aSubst[0]
    If StringInStr($aSubst[$i], ("," & $sWhere)) Then
        If StringInStr($aSubst[$i], ("," & $sWhere & "*")) Then
            $sWhere &= "*"
            $bPossDST = 1
        EndIf
        If StringInStr($aSubst[$i], ("," & $sWhere & ",")) Then $sWhere = _
            StringLeft($aSubst[$i], StringInStr($aSubst[$i], ",") - 1)
        If StringInStr($sWhere, "GMT") = 1 Then $sWhere = "Etc/" & $sWhere
    EndIf
Next

; Fractional UTC/GMT offsets
If StringInStr($sWhere, ":") Then
    $aFrac = StringSplit($sWhere, ":")
    $sWhere = $aFrac[1]
    $iIncr = $aFrac[2]
    If StringInStr($sWhere, "+") Then $iIncr *= -1
EndIf

$sTZdata = "Africa/Abidjan,Africa/Algiers,Africa/Bissau,Africa/Cairo,Africa/Casablanca,Africa/Ceuta,Africa/El_Aaiun,Africa/Johannesburg,Africa/Juba,Africa/Khartoum,Africa/Lagos,Africa/Maputo,Africa/Monrovia,Africa/Nairobi,Africa/Ndjamena,Africa/Sao_Tome,Africa/Tripoli,Africa/Tunis,Africa/Windhoek,America/Adak,America/Anchorage,America/Araguaina,America/Argentina/Buenos_Aires,America/Argentina/Catamarca,America/Argentina/Cordoba,America/Argentina/Jujuy,America/Argentina/La_Rioja,America/Argentina/Mendoza,America/Argentina/Rio_Gallegos,America/Argentina/Salta,America/Argentina/San_Juan,America/Argentina/San_Luis,America/Argentina/Tucuman,America/Argentina/Ushuaia,America/Asuncion,America/Bahia,America/Bahia_Banderas,America/Barbados,America/Belem,America/Belize,America/Boa_Vista,America/Bogota,America/Boise,America/Cambridge_Bay,America/Campo_Grande,America/Cancun,America/Caracas,America/Cayenne,America/Chicago,America/Chihuahua,America/Ciudad_Juarez,America/Costa_Rica,America/Cuiaba,America/Danmarkshavn,America/Dawson,America/Dawson_Creek,America/Denver,America/Detroit,America/Edmonton,America/Eirunepe,America/El_Salvador,America/Fort_Nelson,America/Fortaleza,America/Glace_Bay,America/Goose_Bay,America/Grand_Turk,America/Guatemala,America/Guayaquil,America/Guyana,America/Halifax,America/Havana,America/Hermosillo,America/Indiana/Indianapolis,America/Indiana/Knox,America/Indiana/Marengo,America/Indiana/Petersburg,America/Indiana/Tell_City,America/Indiana/Vevay,America/Indiana/Vincennes,America/Indiana/Winamac,America/Inuvik,America/Iqaluit,America/Jamaica,America/Juneau,America/Kentucky/Louisville,America/Kentucky/Monticello,America/La_Paz,America/Lima,America/Los_Angeles,America/Maceio,America/Managua,America/Manaus,America/Martinique,America/Matamoros,America/Mazatlan,America/Menominee,America/Merida,America/Metlakatla,America/Mexico_City,America/Miquelon,America/Moncton,America/Monterrey,America/Montevideo,America/New_York,America/Nome,America/Noronha,America/North_Dakota/Beulah,America/North_Dakota/Center,America/North_Dakota/New_Salem,America/Nuuk,America/Ojinaga,America/Panama,America/Paramaribo,America/Phoenix,America/Port-au-Prince,America/Porto_Velho,America/Puerto_Rico,America/Punta_Arenas,America/Rankin_Inlet,America/Recife,America/Regina,America/Resolute,America/Rio_Branco,America/Santarem,America/Santiago,America/Santo_Domingo,America/Sao_Paulo,America/Scoresbysund,America/Sitka,America/St_Johns,America/Swift_Current,America/Tegucigalpa,America/Thule,"

$sTZdata &= "America/Tijuana,America/Toronto,America/Vancouver,America/Whitehorse,America/Winnipeg,America/Yakutat,Antarctica/Casey,Antarctica/Davis,Antarctica/Macquarie,Antarctica/Mawson,Antarctica/Palmer,Antarctica/Rothera,Antarctica/Troll,Antarctica/Vostok,Asia/Almaty,Asia/Amman,Asia/Anadyr,Asia/Aqtau,Asia/Aqtobe,Asia/Ashgabat,Asia/Atyrau,Asia/Baghdad,Asia/Baku,Asia/Bangkok,Asia/Barnaul,Asia/Beirut,Asia/Bishkek,Asia/Chita,Asia/Choibalsan,Asia/Colombo,Asia/Damascus,Asia/Dhaka,Asia/Dili,Asia/Dubai,Asia/Dushanbe,Asia/Famagusta,Asia/Gaza,Asia/Hebron,Asia/Ho_Chi_Minh,Asia/Hong_Kong,Asia/Hovd,Asia/Irkutsk,Asia/Jakarta,Asia/Jayapura,Asia/Jerusalem,Asia/Kabul,Asia/Kamchatka,Asia/Karachi,Asia/Kathmandu,Asia/Khandyga,Asia/Kolkata,Asia/Krasnoyarsk,Asia/Kuching,Asia/Macau,Asia/Magadan,Asia/Makassar,Asia/Manila,Asia/Nicosia,Asia/Novokuznetsk,Asia/Novosibirsk,Asia/Omsk,Asia/Oral,Asia/Pontianak,Asia/Pyongyang,Asia/Qatar,Asia/Qostanay,Asia/Qyzylorda,Asia/Riyadh,Asia/Sakhalin,Asia/Samarkand,Asia/Seoul,Asia/Shanghai,Asia/Singapore,Asia/Srednekolymsk,Asia/Taipei,Asia/Tashkent,Asia/Tbilisi,Asia/Tehran,Asia/Thimphu,Asia/Tokyo,Asia/Tomsk,Asia/Ulaanbaatar,Asia/Urumqi,Asia/Ust-Nera,Asia/Vladivostok,Asia/Yakutsk,Asia/Yangon,Asia/Yekaterinburg,Asia/Yerevan,Atlantic/Azores,Atlantic/Bermuda,Atlantic/Canary,Atlantic/Cape_Verde,Atlantic/Faroe,Atlantic/Madeira,Atlantic/South_Georgia,Atlantic/Stanley,Australia/Adelaide,Australia/Brisbane,Australia/Broken_Hill,Australia/Darwin,Australia/Eucla,Australia/Hobart,Australia/Lindeman,Australia/Lord_Howe,Australia/Melbourne,Australia/Perth,Australia/Sydney,CET,CST6CDT,EET,EST,EST5EDT,Etc/GMT,Etc/GMT+1,Etc/GMT+10,Etc/GMT+11,Etc/GMT+12,Etc/GMT+2,Etc/GMT+3,Etc/GMT+4,Etc/GMT+5,Etc/GMT+6,Etc/GMT+7,Etc/GMT+8,Etc/GMT+9,Etc/GMT-1,Etc/GMT-10,Etc/GMT-11,Etc/GMT-12,Etc/GMT-13,Etc/GMT-14,Etc/GMT-2,Etc/GMT-3,Etc/GMT-4,Etc/GMT-5,Etc/GMT-6,Etc/GMT-7,Etc/GMT-8,Etc/GMT-9,Etc/UTC,Europe/Andorra,Europe/Astrakhan,Europe/Athens,Europe/Belgrade,Europe/Berlin,Europe/Brussels,Europe/Bucharest,Europe/Budapest,Europe/Chisinau,Europe/Dublin,Europe/Gibraltar,Europe/Helsinki,Europe/Istanbul,Europe/Kaliningrad,Europe/Kirov,Europe/Kyiv,Europe/Lisbon,Europe/London,Europe/Madrid,Europe/Malta,Europe/Minsk,Europe/Moscow,Europe/Paris,Europe/Prague,Europe/Riga,Europe/Rome,Europe/Samara,Europe/Saratov,Europe/Simferopol,Europe/Sofia,Europe/Tallinn,Europe/Tirane,Europe/Ulyanovsk,Europe/Vienna,Europe/Vilnius,Europe/Volgograd,Europe/Warsaw,Europe/Zurich,HST,Indian/Chagos,Indian/Maldives,Indian/Mauritius,MET,MST,MST7MDT,PST8PDT,Pacific/Apia,Pacific/Auckland,Pacific/Bougainville,Pacific/Chatham,Pacific/Easter,Pacific/Efate,Pacific/Fakaofo,Pacific/Fiji,Pacific/Galapagos,Pacific/Gambier,Pacific/Guadalcanal,Pacific/Guam,Pacific/Honolulu,Pacific/Kanton,Pacific/Kiritimati,Pacific/Kosrae,Pacific/Kwajalein,Pacific/Marquesas,Pacific/Nauru,Pacific/Niue,Pacific/Norfolk,Pacific/Noumea,Pacific/Pago_Pago,Pacific/Palau,Pacific/Pitcairn,Pacific/Port_Moresby,Pacific/Rarotonga,Pacific/Tahiti,Pacific/Tarawa,Pacific/Tongatapu,WET,"

$sSubst = StringReplace($sSubst, "_", " ")
$sSubst = StringReplace($sSubst, "*", "")
$sTZdata &= $sSubst
$aTZdata = StringSplit($sTZdata, ",")

$iMatch = _ListMatches($sWhere)
If Not $iMatch Then
    If Not $sOut Then $sOut = "Nothing on """ & $sWhere & """"
    Exit ConsoleWrite($sOut)
EndIf
$sTail = $aTZdata[$iMatch]
$sURL &= $sTail
$h1 = InetGet($sURL, $sDataFn)
If Not $h1 Then
    If Not $sOut Then
        _ExitError("Nothing on """ & $sWhere & """")
    Else
        Exit ConsoleWrite($sOut & @CRLF)
    EndIf
EndIf
InetClose($h1)
$h2 = FileOpen($sDataFn)
If $h2 < 0 Then _ExitError("Error opening " & $sDataFn)
$sData = FileRead($h2)
FileClose($h2)
If FileExists($sDataFn) Then FileDelete($sDataFn)
$aData = StringSplit($sData, ",")
$sDoW = "Mon|Tue|Wed|Thu|Fri|Sat|Sun"
$aDow = StringSplit($sDoW, "|")
If $iIncr = 0 Then
    $iDoW0 = @WDAY - 1
    If $iDoW0 < 1 Then $iDow0 = 7
    $iDoW1 = StringRight($aData[3], 1)
    $sOut &= $aDoW[$iDow1] & " "
    $sOut &= StringMid($aData[5], 24, 8)
    If $aData[10] = '"dst":true' Then $sOut &= " (DST)"
Else
    $DTime = StringReplace(StringMid($aData[5], 13, 19), "-", "/")
    $DTime = StringReplace($DTime, "T", " ")
    $DTadj = _DateAdd("n", $iIncr, $DTime)
    $aDTm = StringSplit(StringLeft($DTadj, 10), "/")
    $iDow1 = _DateToDayofWeek($aDTm[1], $aDTm[2], $aDTm[3]) - 1
    If $iDoW1 < 1 Then $iDow1 = 7
    $sOut &= $aDoW[$iDoW1] & " " & StringRight($DTadj, 8)
EndIf
If $bPossDST Then $sOut &= @CRLF & "(possibly plus|minus DST offset)"
Exit ConsoleWrite($sOut & @CRLF)

Func _ListMatches($sStr = "")
    Local $iCount = 0, $iIndex = 0, $sFixGMT = "", $sStr0 = ""
    If $sStr Then
        For $i = 1 To $aTZdata[0]
            If StringInStr($aTZdata[$i], $sStr) = 0 Or _
                StringInStr($aTZdata[$i], "|") = 1 Then ContinueLoop
            $iIndex = $i
            $sStr0 = $aTZdata[$i]
            If StringInStr($sStr0, "/") And Not StringInStr($sStr0, "Etc/") Then $sStr0 = StringSplit($sStr0, "/")[2]
            If $sStr0 = $sStr Then
                $sFixGMT = $aTZdata[$i]
                If StringInStr($sFixGMT, "Etc/") = 1 Then
                    $sFixGMT = StringReplace($aTZdata[$i], "Etc/GMT", "UTC/GMT")
                    If StringInStr($sFixGMT, "+") = 8 Then
                        $sFixGMT = StringReplace($sFixGMT, "+", "-")
                    ElseIf StringInStr($sFixGMT, "-") = 8 Then
                        $sFixGMT = StringReplace($sFixGMT, "-", "+")
                    EndIf
                EndIf
                If $iIncr > 0 Then $sFixGMT &= ":" & String(Abs($iIncr))
                $sOut &= $sFixGMT & "  "
                Return $iIndex
            EndIf
            $iCount += 1
            If $iCount = 2 Then $sOut &= @CRLF
            If StringInStr($aTZdata[$i], "Etc/") = 0 Then
                $sOut &= $aTZdata[$i] & "  "
                If $iCount > 1 Then $sOut &= @CRLF
            EndIf
        Next
    EndIf
    If Not $iCount Then
        _ExitError("Nothing on """ & $sStr & """")
    Else
        If $iCount > 1 Then
            $iCount = 0
        Else
            $iCount = $iIndex
        EndIf
    EndIf
    Return $iCount
EndFunc  ;==>_ListMatches

Func _ExitError($sStr = "")
    If $sStr Then ConsoleWrite($sStr & @CRLF)
    Exit
EndFunc  ;==>_ExitError

Func _ShowHelp()
    ConsoleWrite("World Time via WorldTimeAPI " & $sRevDate & _
        @CRLF & "Supplemental time zone data from www.timeanddate.com" & _
        @CRLF & "Usage:" & @CRLF & StringTrimRight(@ScriptName, 4) & _
        " <CITY>" & @CRLF & "--" & @CRLF & StringTrimRight(@ScriptName, 4) &  _
        " <substring> lists cities in database containing <substring>" & _
        @CRLF & "Listings in format <continent>/<city> (e.g., Europe/Lisbon) obtain" & _
        @CRLF & "  the current time from the server at worldtimeapi.org." & @CRLF & _
        "Listings with city name only use an internal database to determine" & _
        @CRLF & "  the applicable UTC/GMT offset." & @CRLF & _
        "Accuracy is NOT guaranteed!" & @CRLF)
EndFunc  ;==>_ShowHelp

 

...so, who wrote this @CarlD ?

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Posted

From the mid 70's the Acronym GMT doesn't have any precise scientific definition. Use UTC instead, including leap seconds!

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...