Microsoft Small Basic

Program Listing: BSP033
' World Clock
' Copyright (c) 2014 Nonki Takahashi. The MIT License.
' Version: 0.1a
' Last update: 2014-11-11
' Program ID:
'
GraphicsWindow.Title = "World Clock 0.1a"
cityLocal = "Tokyo"
city["Sydney"] ="local=+10;DST=+1;hemisphere=south;"
city["Tokyo"] = "local=+9;DST=0;hemeiphere=north;"
city["London"] = "local=0;DST=+1;hemisphere=north;"
city["Seatle"] = "local=-8;DST=+1;hemisphere=north;"
bc = "#000000"
colorDay = "#CCCCCC"
colorNight = "#666666"
colorMidNight = "#333333"
colorHourHand = "#FF9900"
colorText = "#FFFFFF"
gw = 598
gh = 428
GraphicsWindow.Width = gw
GraphicsWindow.Height = gh
GraphicsWindow.BackgroundColor = bc
nCity = Array.GetItemCount(city)
index = Array.GetAllIndices(city)
deltaLocal = city[cityLocal]["local"]
GraphicsWindow.FontName = "Trebuchet MS"
width = Math.Floor((gw - 110) / 24)
height = Math.Floor((gh - 60) / nCity)
For i = 1 To nCity
x = 10
y = 50 + (i - 1) * height
GraphicsWindow.BrushColor = colorText
GraphicsWindow.DrawText(x, y + height / 2 - 10, index[i])
x = 100
hourLocal = city[index[i]]["local"] * 1
If hourLocal < 0 Then
hourLocal = hourLocal + 24
EndIf
For hourGMT = 0 To 23
If 6 <= hourLocal And hourLocal < 18 Then
GraphicsWindow.BrushColor = colorDay
ElseIf 18 <= hourLocal Then
GraphicsWindow.BrushColor = colorNight
Else
GraphicsWindow.BrushColor = colorMidNight
EndIf
GraphicsWindow.FillRectangle(x, y + 10, width - 1, height - 20)
If 6 <= hourLocal And hourLocal < 18 Then
GraphicsWindow.BrushColor = colorMidNight
Else
GraphicsWindow.BrushColor = colorDay
EndIf
GraphicsWindow.DrawText(x, y + 10, hourLocal)
x = x + width
hourLocal = hourLocal + 1
If 24 <= hourLocal Then
hourLocal = hourLocal - 24
EndIf
EndFor
EndFor
y = 60
GraphicsWindow.PenColor = colorHourHand
hourHand = Shapes.AddLine(0, 0, 0, gh - 80)
Timer.Interval = 500
Timer.Tick = OnTick
Sub OnTick
hourGMT = Clock.Hour - city[cityLocal]["local"]
If hourGMT < 0 Then
hourGMT = hourGMT + 24
EndIf
If 24 <= hourGMT Then
hourGMT = hourGMT - 24
EndIf
hourGMT = hourGMT + Clock.Minute / 60
x = 100 + Math.Floor(hourGMT * width)
Shapes.Move(hourHand, x, y)
EndSub