Timezone Output

Share your favorite FastKeys commands
Post Reply
30fold
Posts: 7
Joined: Nov 29th, ’15, 09:36

Post by 30fold » Aug 21st, ’20, 05:47

Looking through the docs this may not be possible. I often need to output an event time in the 4 major US time zones. For example, start the macro and it asks for input. So I input 11:55 AM and the output text is 11:55 AM PAC, 12:55 PM MTN, 1:55 PM CTR, 2:55 PM EST. In other words, the macro would take in the PAC time and calculate the other 3. I didn't see a way to operate on the variables I create. Anyone out there know how this can be done?
User avatar
Marko
Posts: 1230
Joined: Mar 2nd, ’13, 21:02

Post by Marko » Aug 21st, ’20, 07:54

Yes, in Send mode you can use Input or Select macros and then Insert command code macro.

For example:
%INPUT_Time%%CODE_CalcTime%

Code: Select all

RegExMatch(INPUT_Time, "i)(\d\d):(\d\d) ?(PM)?", t)
if t3 ; PM
    t1 += 12
time := A_YYYY A_MM A_DD t1 t2

time += 1, hours
FormatTime, time1, %time%, Time

time += 1, hours
FormatTime, time2, %time%, Time

time += 1, hours
FormatTime, time3, %time%, Time

Send, % " PAC, " time1 " MTN, " time2 " CTR, " time3 " EST`n"
30fold
Posts: 7
Joined: Nov 29th, ’15, 09:36

Post by 30fold » Aug 21st, ’20, 08:45

That's AWESOME, Marco. Thank you for the quick reply. I used AHK years ago, so I will have to brush up on the language, but this is perfect for now. I just used it and it works perfectly.
30fold
Posts: 7
Joined: Nov 29th, ’15, 09:36

Post by 30fold » Nov 17th, ’20, 22:51

This has been an awesome solution. I did find though that it needs a 2 digit time to leed off. So if, for example, an event begins at 9 AM, I have to say 09:00 AM. And since the first output is simply the echoing of the input box I get 09:00 AM Pacific, 10:00 AM Mountain, 11:00 AM Central, 12:00 PM Eastern rather than 9:00 AM Pacific, 10:00 AM Mountain, 11:00 AM Central, 12:00 PM Eastern. I've tried editing the code but fine my coding skills quite diminished.
User avatar
Marko
Posts: 1230
Joined: Mar 2nd, ’13, 21:02

Post by Marko » Nov 21st, ’20, 20:10

Something like this?

Code: Select all

RegExMatch(INPUT_Time, "i)(\d*):(\d\d) ?(PM)?", t)
if t3 ; PM
    t1 += 12
time := A_YYYY A_MM A_DD ((StrLen(t1)=1)?"0":"") t1 t2

time += 1, hours
FormatTime, time1, %time%, Time

time += 1, hours
FormatTime, time2, %time%, Time

time += 1, hours
FormatTime, time3, %time%, Time

Send, % " PAC, " time1 " MTN, " time2 " CTR, " time3 " EST`n"
Post Reply