The official site of Four13 Designs offering downloads for DesktopX.
Daylight savings time
Published on April 26, 2005 By Sranshaft In DesktopX
As the title suggests, I'm having difficulty with my World Clock adjusting to Daylight Savings Time. Below is the code I'm using which works fine but does not take into account the loss or gain of an hour depending on which city is selected. I've tried having it look to see what month we are in and adjusting from there but it didn't seem to work.

[code]

Dim GMT

'Called when the script is executed
Sub Object_OnScriptEnter
GMT = 15
Control.BackColor = RGB(252,252,252)
Control.ForeColor = RGB(42,42,42)
Control.SelectionBackColor = RGB(128,140,155)
Control.SelectionForeColor = RGB(252,252,252)
Control.AddItem "Midway Island"
Control.AddItem "Honolulu"
Control.AddItem "Los Angelos"
Control.AddItem "Seattle"
Control.AddItem "Albuquerque"
Control.AddItem "Dallas"
Control.AddItem "Mexico City"
Control.AddItem "New York"
Control.AddItem "Philadelphia"
Control.AddItem "Washington, DC"
Control.AddItem "Miami"
Control.AddItem "Buenos Aires"
Control.AddItem "Dublin"
Control.AddItem "London"
Control.AddItem "Lisbon"
Control.AddItem "Berlin"
Control.AddItem "Amsterdam"
Control.AddItem "Rome"
Control.AddItem "Paris"
Control.AddItem "Madrid"
Control.AddItem "Warsaw"
Control.AddItem "Athens"
Control.AddItem "Instanbul"
Control.AddItem "Bucharest"
Control.AddItem "Cairo"
Control.AddItem "Helsinki"
Control.AddItem "Jerusalem"
Control.AddItem "Baghdad"
Control.AddItem "Riyadh"
Control.AddItem "Moscow"
Control.AddItem "St. Petersburg"
Control.AddItem "Nairobi"
Control.AddItem "Bangkok"
Control.AddItem "Jakarta"
Control.AddItem "Beijing"
Control.AddItem "Hong Kong"
Control.AddItem "Singapore"
Control.AddItem "Kuala Lumpur"
Control.AddItem "Perth"
Control.AddItem "Taipei"
Control.AddItem "Tokyo"
Control.AddItem "Seoul"
Control.AddItem "Brisbane"
Control.AddItem "Melbourne"
Control.AddItem "Werribee"
Control.AddItem "Sydney"
Control.AddItem "Canberra"
Control.AddItem "Guam"
Control.AddItem "Auckland"
Control.AddItem "Fiji"
Control.ListIndex = 0
End Sub

Sub Control_OnSelect(item, string)

If Control.Text = "Midway Island" Then
DesktopX.Object("anaLocation1").Text = "MIDWAY ISLAND"
DesktopX.ScriptObject("anaHour1").Offset = GMT - 11
ElseIf Control.Text = "Honolulu" Then
DesktopX.Object("anaLocation1").Text = "HONOLULU"
DesktopX.ScriptObject("anaHour1").Offset = GMT - 10
ElseIf Control.Text = "Los Angelos" Then
DesktopX.Object("anaLocation1").Text = "LOS ANGELOS"
DesktopX.ScriptObject("anaHour1").Offset = GMT - 8
ElseIf Control.Text = "Seattle" Then
DesktopX.Object("anaLocation1").Text = "SEATTLE"
DesktopX.ScriptObject("anaHour1").Offset = GMT - 8
ElseIf Control.Text = "Albuquerque" Then
DesktopX.Object("anaLocation1").Text = "ALBUQUERQUE"
DesktopX.ScriptObject("anaHour1").Offset = GMT - 7
ElseIf Control.Text = "Dallas" Then
DesktopX.Object("anaLocation1").Text = "DALLAS"
DesktopX.ScriptObject("anaHour1").Offset = GMT - 6
ElseIf Control.Text = "Mexico City" Then
DesktopX.Object("anaLocation1").Text = "MEXICO CITY"
DesktopX.ScriptObject("anaHour1").Offset = GMT - 6
ElseIf Control.Text = "New York" Then
DesktopX.Object("anaLocation1").Text = "NEW YORK"
DesktopX.ScriptObject("anaHour1").Offset = GMT - 5
ElseIf Control.Text = "Philadelphia" Then
DesktopX.Object("anaLocation1").Text = "PHILADELPHIA"
DesktopX.ScriptObject("anaHour1").Offset = GMT - 5
ElseIf Control.Text = "Washington, DC" Then
DesktopX.Object("anaLocation1").Text = "WASHINGTON, DC"
DesktopX.ScriptObject("anaHour1").Offset = GMT - 5
ElseIf Control.Text = "Miami" Then
DesktopX.Object("anaLocation1").Text = "MIAMI"
DesktopX.ScriptObject("anaHour1").Offset = GMT - 5
ElseIf Control.Text = "Buenos Aires" Then
DesktopX.Object("anaLocation1").Text = "BUENOS AIRES"
DesktopX.ScriptObject("anaHour1").Offset = GMT - 3
ElseIf Control.Text = "Dublin" Then
DesktopX.Object("anaLocation1").Text = "DUBLIN"
DesktopX.ScriptObject("anaHour1").Offset = GMT + 0
ElseIf Control.Text = "London" Then
DesktopX.Object("anaLocation1").Text = "LONDON"
DesktopX.ScriptObject("anaHour1").Offset = GMT + 0
ElseIf Control.Text = "Lisbon" Then
DesktopX.Object("anaLocation1").Text = "LISBON"
DesktopX.ScriptObject("anaHour1").Offset = GMT + 0
ElseIf Control.Text = "Berlin" Then
DesktopX.Object("anaLocation1").Text = "BERLIN"
DesktopX.ScriptObject("anaHour1").Offset = GMT + 1
ElseIf Control.Text = "Amsterdam" Then
DesktopX.Object("anaLocation1").Text = "AMSTERDAM"
DesktopX.ScriptObject("anaHour1").Offset = GMT + 1
ElseIf Control.Text = "Rome" Then
DesktopX.Object("anaLocation1").Text = "ROME"
DesktopX.ScriptObject("anaHour1").Offset = GMT + 1
ElseIf Control.Text = "Paris" Then
DesktopX.Object("anaLocation1").Text = "PARIS"
DesktopX.ScriptObject("anaHour1").Offset = GMT + 1
ElseIf Control.Text = "Madrid" Then
DesktopX.Object("anaLocation1").Text = "MADRID"
DesktopX.ScriptObject("anaHour1").Offset = GMT + 1
ElseIf Control.Text = "Warsaw" Then
DesktopX.Object("anaLocation1").Text = "WARSAW"
DesktopX.ScriptObject("anaHour1").Offset = GMT + 1
ElseIf Control.Text = "Athens" Then
DesktopX.Object("anaLocation1").Text = "ATHENS"
DesktopX.ScriptObject("anaHour1").Offset = GMT + 2
ElseIf Control.Text = "Istanbul" Then
DesktopX.Object("anaLocation1").Text = "ISTANBUL"
DesktopX.ScriptObject("anaHour1").Offset = GMT + 2
ElseIf Control.Text = "Bucharest" Then
DesktopX.Object("anaLocation1").Text = "BUCHAREST"
DesktopX.ScriptObject("anaHour1").Offset = GMT + 2
ElseIf Control.Text = "Cairo" Then
DesktopX.Object("anaLocation1").Text = "CARIO"
DesktopX.ScriptObject("anaHour1").Offset = GMT + 2
ElseIf Control.Text = "Helsinki" Then
DesktopX.Object("anaLocation1").Text = "HELSINKI"
DesktopX.ScriptObject("anaHour1").Offset = GMT + 2
ElseIf Control.Text = "Jerusalem" Then
DesktopX.Object("anaLocation1").Text = "JERUSALEM"
DesktopX.ScriptObject("anaHour1").Offset = GMT + 2
ElseIf Control.Text = "Baghdad" Then
DesktopX.Object("anaLocation1").Text = "BAGHDAD"
DesktopX.ScriptObject("anaHour1").Offset = GMT + 3
ElseIf Control.Text = "Riyahd" Then
DesktopX.Object("anaLocation1").Text = "RIYAHD"
DesktopX.ScriptObject("anaHour1").Offset = GMT + 3
ElseIf Control.Text = "Moscow" Then
DesktopX.Object("anaLocation1").Text = "MOSCOW"
DesktopX.ScriptObject("anaHour1").Offset = GMT + 3
ElseIf Control.Text = "St. Petersburg" Then
DesktopX.Object("anaLocation1").Text = "ST. PETERSBURG"
DesktopX.ScriptObject("anaHour1").Offset = GMT + 3
ElseIf Control.Text = "Bangkok" Then
DesktopX.Object("anaLocation1").Text = "BANGKOK"
DesktopX.ScriptObject("anaHour1").Offset = GMT + 7
ElseIf Control.Text = "Jakarta" Then
DesktopX.Object("anaLocation1").Text = "JAKARTA"
DesktopX.ScriptObject("anaHour1").Offset = GMT + 7
ElseIf Control.Text = "Beijing" Then
DesktopX.Object("anaLocation1").Text = "BEIJING"
DesktopX.ScriptObject("anaHour1").Offset = GMT + 8
ElseIf Control.Text = "Hong Kong" Then
DesktopX.Object("anaLocation1").Text = "HONG KONG"
DesktopX.ScriptObject("anaHour1").Offset = GMT + 8
ElseIf Control.Text = "Singapore" Then
DesktopX.Object("anaLocation1").Text = "SINGAPORE"
DesktopX.ScriptObject("anaHour1").Offset = GMT + 8
ElseIf Control.Text = "Kuala Lumpur" Then
DesktopX.Object("anaLocation1").Text = "KUALA LAMPUR"
DesktopX.ScriptObject("anaHour1").Offset = GMT + 8
ElseIf Control.Text = "Perth" Then
DesktopX.Object("anaLocation1").Text = "PERTH"
DesktopX.ScriptObject("anaHour1").Offset = GMT + 8
ElseIf Control.Text = "Taipei" Then
DesktopX.Object("anaLocation1").Text = "TAIPEI"
DesktopX.ScriptObject("anaHour1").Offset = GMT + 8
ElseIf Control.Text = "Tokyo" Then
DesktopX.Object("anaLocation1").Text = "TOKYO"
DesktopX.ScriptObject("anaHour1").Offset = GMT + 9
ElseIf Control.Text = "Seoul" Then
DesktopX.Object("anaLocation1").Text = "SEOUL"
DesktopX.ScriptObject("anaHour1").Offset = GMT + 9
ElseIf Control.Text = "Brisbane" Then
DesktopX.Object("anaLocation1").Text = "BRISBANE"
DesktopX.ScriptObject("anaHour1").Offset = GMT + 10
ElseIf Control.Text = "Melbourne" Then
DesktopX.Object("anaLocation1").Text = "MELBOURNE"
DesktopX.ScriptObject("anaHour1").Offset = GMT + 12
ElseIf Control.Text = "Werribee" Then
DesktopX.Object("anaLocation1").Text = "WERRIBEE"
DesktopX.ScriptObject("anaHour1").Offset = GMT + 12
ElseIf Control.Text = "Sydney" Then
DesktopX.Object("anaLocation1").Text = "SYDNEY"
DesktopX.ScriptObject("anaHour1").Offset = GMT + 12
ElseIf Control.Text = "Canberra" Then
DesktopX.Object("anaLocation1").Text = "CANBERRA"
DesktopX.ScriptObject("anaHour1").Offset = GMT + 12
ElseIf Control.Text = "Guam" Then
DesktopX.Object("anaLocation1").Text = "GUAM"
DesktopX.ScriptObject("anaHour1").Offset = GMT + 10
ElseIf Control.Text = "Auckland" Then
DesktopX.Object("anaLocation1").Text = "AUCKLAND"
DesktopX.ScriptObject("anaHour1").Offset = GMT + 12
ElseIf Control.Text = "Fiji" Then
DesktopX.Object("anaLocation1").Text = "FIJI"
DesktopX.ScriptObject("anaHour1").Offset = GMT + 12
End If
End Sub

[/code]

Anyone have any ideas???

Comments
on Apr 27, 2005
The thing is that not everyone use daylight setting. So how would people know what city to pick in order to get what's right for them, unless they live in that city. Would it work if you simply had a checkbox to indicate whether to use daylight saving or not. Then add that to you calculation.

Another thing, isn't GMT affected by daylight saving time? So if you use GMT as a base, won't all ther other times be adjusted similary as as well?
on Apr 27, 2005
GMT does not change due to daylight saving times. The time in Greenwich does but then it is British Summer Time and not GMT.
Its probably better to use UTC rather than GMT. They are the same but UTC is the now the standard term used.
on Apr 27, 2005
This site will probably be useful for you.

Sources for Time Zone and Daylight Saving Time Data
Link