Jump to content

Clock with a different time zone


Recommended Posts

I am trying to make a gui with a couple digital clocks in it, that each have a different time zone. I looked on the forum, and all I see is complicated gui pretty analog clocks. Is there a basic way to display the current time in another time zone? If someone could point me to the right direction of one clock with time zone support, I will expand it to have a couple clocks which each have their own time zone.

it would be better to have the seconds refresh realtime (while loop).

Link to comment
Share on other sites

Start with GetTimeZoneInformation API function

http://msdn.microsoft.com/en-us/library/ms724421(VS.85).aspx

There are also other time API functions out there

http://msdn.microsoft.com/en-us/library/ms725473(VS.85).aspx

You may look at my Radar project (in my signature) where I used GetTimeZoneInformation API function to recognize summer/winter (daylight) time.

Link to comment
Share on other sites

Thanks Zedna. I haven't dove into API's yet, not that I am new to Autoit, but don't have a deep knowledge of programming.

I decided to go simple.

#include <GUIConstants.au3>

$Form = GUICreate("TimeZone GUI", 116, 183, 193, 125)

$BCLabel = GUICtrlCreateLabel("BC: " , 10, 16, 45, 17)

$BC = GUICtrlCreateLabel(@HOUR-3 & ":" & @MIN & ":" & @SEC , 44, 16, 45, 17)

$ONTLabel = GUICtrlCreateLabel("ONT: " , 10, 46, 45, 17)

$ONT = GUICtrlCreateLabel(@HOUR & ":" & @MIN & ":" & @SEC , 44, 46, 45, 17)

GUISetState(@SW_SHOW)

While 1

GUICtrlSetData($BC,@HOUR-3 & ":" & @MIN & ":" & @SEC )

GUICtrlSetData($ONT,@HOUR & ":" & @MIN & ":" & @SEC )

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

EndSwitch

WEnd

Link to comment
Share on other sites

Thanks Zedna. I haven't dove into API's yet, not that I am new to Autoit, but don't have a deep knowledge of programming.

I decided to go simple.

#include <GUIConstants.au3>

$Form = GUICreate("TimeZone GUI", 116, 183, 193, 125)

$BCLabel = GUICtrlCreateLabel("BC: " , 10, 16, 45, 17)

$BC = GUICtrlCreateLabel(@HOUR-3 & ":" & @MIN & ":" & @SEC , 44, 16, 45, 17)

$ONTLabel = GUICtrlCreateLabel("ONT: " , 10, 46, 45, 17)

$ONT = GUICtrlCreateLabel(@HOUR & ":" & @MIN & ":" & @SEC , 44, 46, 45, 17)

GUISetState(@SW_SHOW)

While 1

GUICtrlSetData($BC,@HOUR-3 & ":" & @MIN & ":" & @SEC )

GUICtrlSetData($ONT,@HOUR & ":" & @MIN & ":" & @SEC )

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

EndSwitch

WEnd

That is flickering. Try this:

#include <GUIConstants.au3>

Global $Form = GUICreate("TimeZone GUI", 116, 183, 193, 125)

Global $BCLabel = GUICtrlCreateLabel("BC: ", 10, 16, 45, 17)
Global $BC = GUICtrlCreateLabel("", 44, 16, 45, 17)

Global $ONTLabel = GUICtrlCreateLabel("ONT: ", 10, 46, 45, 17)
Global $ONT = GUICtrlCreateLabel("", 44, 46, 45, 17)

Global $iHour, $iMin, $iSec, $iSecNew

GUISetState(@SW_SHOW)

While 1
    $iSecNew = @SEC
    If $iSecNew <> $iSec Then
        $iHour = @HOUR
        $iMin = @MIN
        GUICtrlSetData($BC, $iHour - 3 & ":" & $iMin & ":" & $iSecNew)
        GUICtrlSetData($ONT, $iHour & ":" & $iMin & ":" & $iSecNew)
        $iSec = $iSecNew
    EndIf
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

That is flickering. Try this:

#include <GUIConstants.au3>

Global $Form = GUICreate("TimeZone GUI", 116, 183, 193, 125)

Global $BCLabel = GUICtrlCreateLabel("BC: ", 10, 16, 45, 17)
Global $BC = GUICtrlCreateLabel("", 44, 16, 45, 17)

Global $ONTLabel = GUICtrlCreateLabel("ONT: ", 10, 46, 45, 17)
Global $ONT = GUICtrlCreateLabel("", 44, 46, 45, 17)

Global $iHour, $iMin, $iSec, $iSecNew

GUISetState(@SW_SHOW)

While 1
    $iSecNew = @SEC
    If $iSecNew <> $iSec Then
        $iHour = @HOUR
        $iMin = @MIN
        GUICtrlSetData($BC, $iHour - 3 & ":" & $iMin & ":" & $iSecNew)
        GUICtrlSetData($ONT, $iHour & ":" & $iMin & ":" & $iSecNew)
        $iSec = $iSecNew
    EndIf
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Great, that works good. Thanks

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

  • Recently Browsing   0 members

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