I originally posted this on Reddit. I meant to post it here as well but forgot until today. This version has all the modifications I've made to it since the original post on Reddit.
I needed a tool to help people at work, across multiple time zones, to both help others understand what time it is for them, and help schedule various maintenance & Meetings during UTC time and to understand what local time that is for everyone else.
I started off with a snippet of someone else's code that only adjusted minutes of the currently selected day and expanded on it, into this tool.
NOW, this should be fully working for UTC, India time, Eastern, Central, Mountain, and Pacific time zones for a selected date and time.
If you can make it better, awesome! but this should be fully functional out of the box:
Code: Select all
#SingleInstance Force
Gui, add, checkbox, x2 y162 vdst, Check if you're observing DST right now.
Gui, add, combobox, x2 w235 vtzselect, Select Your Timezone||UTC|INDIAN|EASTERN|CENTRAL|MOUNTAIN|PACIFIC
Gui, add, groupbox, x8 y201 w95 h50 cpurple,
Gui, Add, Text, x18 y210 w80 h20 ,24-HH : Min
Gui, Add, Edit, x20 y228 w30 h18 vth Number Limit2, ;hour
Gui, Add, Text, x53 y230 w5 h18 , :
Gui, Add, Edit, x+1 y228 w30 h18 vtm Number Limit2, ;mins
Gui, Add, Button, x110 y208 w130 h40 gConvertTime, Convert Timezones
Gui, Add, MonthCal, x2 y0 w240 h160 vdt,
Gui, Add, Edit,ReadOnly x2 w243 r1 cred vutc, UTC:
Gui, Add, Edit,ReadOnly x2 w243 r6 vallutc, India:`nET:`nCT:`nMT:`nPT:
Gui, Add, button, x2 gcopyall, Copy All
Gui, Add, button, x+25 grightnow, HH/MM Now
Gui, Add, button, x+25 cgray gabout, About
Gui, Show, x318 y270 h400 w250, UTCnator
Return
GuiClose:
ExitApp
ConvertTime:
gui,submit,nohide
;------------------
; Set the selected date in YYYYMMDDHHMMSS
;------------------
TotalDate := dt th tm "00"
;------------------
; Convert adjustments for "Your" timezone to other people's time zones
;------------------
If (tzselect = "Select Your Timezone") {
MsgBox You didn't set YOUR local timezone
return
}
thLength := StrLen(th)
If (thLength < "2") {
MsgBox, You must use 2 digits for hours.`n`nExample:`n02 for 2AM.`n14 for 2PM
return
}
tmLength := StrLen(tm)
If (tmLength < "2") {
MsgBox, You must enter 2 digits for minutes.`n05 for 5 minutes etc.
return
}
;------------------
; UTC time set
;------------------
; UTC +5.5 for Indian.
; UTC -4 for Eastern
; UTC -5 for Central
; UTC -6 for Mountain
; UTC -7 for Pacific
If (tzselect = "UTC") {
if (dst = "1"){
eutc = -5
cutc = -6
mutc = -7
putc = -8
}
else,
{
eutc = -4
cutc = -5
mutc = -6
putc = -7
}
gosub, setbasetimezone
;~ UTotalDate += -5.5, Hours ; Create UTC for India
ITotalDate += 5.5, Hours
ETotalDate += eutc, Hours
CTotalDate += cutc, Hours
MTotalDate += mutc, Hours
PTotalDate += putc, Hours
gosub, settime
}
;------------------
; INDIA time set
;------------------
If (tzselect = "INDIAN") {
; UTC +5.5 for Indian. India does not observe DST. No DST adjustments will be made.
gosub, setbasetimezone
UTotalDate += -5.5, Hours ; Create UTC for India
ETotalDate += -9.5, Hours
CTotalDate += -10.5, Hours
MTotalDate += -11.5, Hours
PTotalDate += -12.5, Hours
gosub, settime
}
;------------------
; EASTERN time set
;------------------
If (tzselect = "EASTERN") {
; UTC -4 for Eastern
if (dst = "1"){
eutc = 5
}
else,
{
eutc = 4
}
gosub, setbasetimezone
UTotalDate += eutc, Hours ; Create UTC for Eastern
ITotalDate += 9.5, Hours
CTotalDate += -1, Hours
MTotalDate += -2, Hours
PTotalDate += -3, Hours
gosub, settime
}
;------------------
; CENTRAL time set
;------------------
If (tzselect = "CENTRAL") {
; UTC -5 for Central
if (dst = "1"){
eutc = 6
}
else,
{
eutc = 5
}
gosub, setbasetimezone
UTotalDate += eutc, Hours ; Create UTC for Central
ITotalDate += 10.5, Hours
ETotalDate += 1, Hours
MTotalDate += -1, Hours
PTotalDate += -2, Hours
gosub, settime
}
;------------------
; MOUNTAIN time set
;------------------
If (tzselect = "MOUNTAIN") {
; UTC -6 for Mountain
if (dst = "1"){
eutc = 7
}
else,
{
eutc = 6
}
gosub, setbasetimezone
UTotalDate += eutc, Hours ; Create UTC for Mountain
ITotalDate += 11.5, Hours
ETotalDate += 2, Hours
CTotalDate += 1, Hours
PTotalDate += -1, Hours
gosub, settime
}
;------------------
; PACIFIC time set
;------------------
If (tzselect = "PACIFIC") {
; UTC -7 for Pacific
if (dst = "1"){
eutc = 8
}
else,
{
eutc = 7
}
gosub, setbasetimezone
UTotalDate += eutc, Hours ; Create UTC for Pacific
ITotalDate += 12.5, Hours
ETotalDate += 3, Hours
CTotalDate += 2, Hours
MTotalDate += 1, Hours
gosub, settime
}
return
;------------------
; Set Local time variables before TimeZone adjustments
;------------------
setbasetimezone:
UTotalDate:=ITotalDate:=ETotalDate:=CTotalDate:=MTotalDate:=PTotalDate:=TotalDate
return
;------------------
; Format YYYYMMDDHHMMSS into time & long date & Set inside GUI
;------------------
settime:
; Format time into long date
FormatTime, utctime, %Utotaldate%,
FormatTime, itime, %ITotalDate%,
FormatTime, etime, %ETotalDate%,
FormatTime, ctime, %CTotalDate%,
FormatTime, mtime, %MTotalDate%,
FormatTime, ptime, %PTotalDate%,
; Show new formatted times in GUI
GuiControl,,utc, UTC: %utctime%
GuiControl,,allutc, India: %itime%`nET: %etime%`nCT: %ctime%`nMT: %mtime%`nPT: %ptime%
;~ GuiControl,,et, ET: %etime%
;~ GuiControl,,ct, CT: %ctime%
;~ GuiControl,,mt, MT: %mtime%
;~ GuiControl,,pt, PT: %ptime%
return
rightnow:
GuiControl,,tzselect,
GuiControl,,utc, UTC: %utctime%
GuiControl,,allutc, India:`nET: `nCT: `nMT: `nPT:
GuiControl,,th, %A_Hour%
GuiControl,,tm, %A_Min%
return
;------------------
; Copy All Button
;------------------
copyall:
If (tzselect = "Select Your Timezone") {
MsgBox You didn't set YOUR local timezone
return
}
clipboard = UTC: %utctime%`nIndia:%itime%`nET: %etime%`nCT: %ctime%`nMT: %mtime%`nPT: %ptime%
MsgBox, The following has been copied to your clipboard:`n`nUTC: %utctime%`nIndia:%itime%`nET: %etime%`nCT: %ctime%`nMT: %mtime%`nPT: %ptime%
return
;------------------
; About Link
;------------------
about:
MsgBox, The DST checkbox will affect UTC time but not the current selected time for the local.`n`nFor example, On the East Coast, UTC is:`n- 5 hours ahead of local time during winter.`n- 4 hours ahead during summer.`n`n** India does not observe Daylight Savings Time so no adjustments to UTC when the local timezone is set to India.
return
return