QA Graphic

Time Zone Convert

Easy way to convert a time to different time zones.

This past week I was scheduling a meeting with a counterpart in California. I was looking for an easy way to let them know the time of the meeting using Slack. I thought there would be some plug in to automatically display a time in EDT to other timezones.

There isn't a Slack tool. Instead of giving up, I decided to make a quick action in Keyboard Maestro.

TimeZone Convert Action

This macro is triggered via the status menu - since it's something that I don't use all the time. When I select the entry, a dialog box opens up and asks me to select the meeting time.

After I click 'OK' the output of the Macro will be sent to the clipboard.

Dialog Box

Meeting Time Dialog

After clicking 'ok' the following data is in the clipboard:

The meeting is at 4:00 PM EDT / 3:00 PM CDT / 1:00 PM PST

I can paste the clipboard data in Slack, Email, Facebook, or anyplace I need.

Keyboard Maestro Macro

This is what my macro looks like in Keyboard Maestro. I used the "Prompt for User Input" and "Execute Shell Script" actions.

Time Zone Converter

Python Shell Code

Provided here so you don't have to type in the information in the above screenshot

#!/usr/bin/env /usr/bin/python3
import datetime
import os
from datetime import datetime as dt, timedelta
from dateutil import relativedelta
kmTime=int(os.environ['KMVAR_Time'])
dt_object = dt.fromtimestamp(kmTime)
est = dt_object + relativedelta.relativedelta();
pst = dt_object + relativedelta.relativedelta(hours=-3);
cst = dt_object + relativedelta.relativedelta(hours=-1);
print(f'The meeting is at {est.strftime("%-I:%M %p")} EDT / {cst.strftime("%-I:%M %p")} CDT / {pst.strftime("%-I:%M %p")} PST')

Some Notes

I used Python instead of the built-in ICUDateTime function because it was a bit complicated to pass through a variable to the ICUDateTime function.

This Python shell script is a good example of how to pass Keyboard Maestro variables to Python.

I am sure the Python code could be cleaned up - just thought I share it in the basic form.

 

Comments

Add Comments

Name:
Comment:

 

About

These posts highlights some cool examples of why Keyboard Maestro should be part of every Mac OS user's computer. Keyboard Maestro is a powerful automation tool that can help improve productivity, save time, and streamline tedious tasks. It has a wide range of features and functions that can be customized to suit any user's needs, making it an ideal choice for Mac OS users.

Schedule

FridayMacintosh
SaturdayInternet Tools
SundayOpen Topic
Monday Media Monday
TuesdayQA
WednesdaySnagIt for QA
ThursdayPython