Jump to content

Paste different timezones hotkey using selected time text.


Recommended Posts

Hello everyone!

I'm want to create a hotkey that will pass through the current selected text and then replace it with other text.  The text that I want to select and copy is a time stamp and then paste that same time in various other timezones.  Basically, I want to select a time stamp and then paste a string that displays that same time in various other time zones. 

 

For example, imagine that there was some text that stated just "1pm CST".  I want to be able to select that text and when I hit a hotkey, have that text replaced with the following text:

"12pm PST / 1pm CST / 2pm EST".

The text that I would be selecting would always be in CST, if that helps.

 

Is there a way to do this ?

Edited by BetaBeats
Link to comment

Hi @BetaBeats, welcome to the forum.

 

Alfred can certainly handle getting the selected text and replacing it, but you'll need some kind of custom script to parse the date and convert it to different timezones.

 

The hard part is parsing the dates. Can you be more specific about what you expect the workflow to understand (i.e. different date/time formats)? The less variable the input, the easier it is to do.

Link to comment

Agreed on complexity increasing with varying timestamp formats.  For this reason, I'm looking to make the workflow as simplistic and easy as possible - even at the cost of flexibility.  Whatever timestamp format is easier to read into a script that then spits out the formatted text I have in my original comment, I'll go with it.  Unless, of course, the timestamp format is something really long to type out like: "Mon, 15 Mar 2021 23:25:30 +0000"

Link to comment
8 hours ago, BetaBeats said:

Whatever timestamp format is easier to read into a script that then spits out the formatted text

 

One format isn't really easier than the other to parse. It gets complicated when it needs to understand many different formats.

 

So you have to be precise about what it should be able to do. I mean, if I build you a workflow based on your current description, it will only understand input like "1pm" or "7am", not "2:30am" or "20:50" or "6am on 01/02/21" etc.

Link to comment

Yes, agreed.  I'm just looking for the most simplistic workflow just so that I can have something working.  The workflow can be restricted to just one format to parse.  Doesn't really matter.  Basically, whatever will get this thing working, even if it's one format, one simplistic format - whatever - just as long as it works.

Link to comment

@BetaBeats Welcome to the forum :) 

 

Can I make a suggestion that falls at the completely simplistic end of the scale? I've created a proof of concept workflow just for fun, which takes the selection in macOS. It assumes that the copied text contains the time zone, such as your "12pm PST" example in your first reply. I can then choose from a list filter which time zone I want the output in, then press return.

 

All it does is launch a phrase in Google Search using your first input (your copied timestamp) and the time zone you requested, and asks Google to calculate it.

 

Screenshot 2021-03-16 at 15.16.24.png

 

This means you don't have to do any calculations or write a single line of code, but requires that you have a live internet connection. The biggest advantage is that Google does the parsing of the date you provided, so there's much less worry about feeding in a specific date format for your script to handle.

 

Currently, it only has a single time zone to offer, but I'll let you fill in the blanks if it's useful :)  I guess you could add not only time zones to the list filter but also cities you frequently need, etc...

 

Here's the link to the workflow:

https://www.dropbox.com/s/dkqxb6wxudgdngl/What time is it somewhere else%3F.alfredworkflow?dl=0

 

[Edited to add: I re-read your post and I remember now that you wanted an in-and-out replacement where the output time zone is automatically pasted as a replacement to the original one. This definitely doesn't go that far, but it really is simple and flexible. ;) ]

 

Cheers,
Vero

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...