Jump to content


Photo

TimeZones - a World Clock script filter [updated to v1.7]

workflows time script filter utilities

  • Please log in to reply
88 replies to this topic

#1 CarlosNZ

CarlosNZ

    Advanced Member

  • Member
  • PipPipPip
  • 369 posts
  • LocationAuckland, New Zealand

Posted 01 February 2013 - 12:37 PM

Here's another little tool I've just whipped up:

 

screenshotnew.png

Get an instant list of the current time in various cities around the world. Which you can customize, of course.

 

  • Main keyword: tz (for TimeZones) - this just shows the World Clock list (seen above). (Select a city for a Large Type display.)
  • To remove a city from the list - option-select it.
  • To add a new city - timezone add Name of City
  • To update all cities' timezone offset information - timezone update
  • To look up the time in a place without storing it (custom loookup), just keep typing the place name after the initial tz (eg. tz timbuktu)
  • To move the location of your stored city list - timezone move

Download v1.7

 

This workflow saves a list of your cities and their UTC offsets locally, so the basic world clock will display instantly. Adding new city information is done via an API call to Google Wolfram Alpha. The only downside to locally cached offsets is that there's no provision for automatically updating for Daylight Savings changes, but a manual timezone update will refresh all the cities with their current offset.

 

Enjoy. As usual, I welcome comments, bug reports, feature requests, etc. :)

 

----

 

28 March 2013 - UPDATE to v1.5

  • Major rewrite - now uses Google Maps APIs, which should be a lot more reliable and consistent.
  • Flag icons! Bit of eye candy, courtesy of http://www.free-country-flags.com (and managed to squeeze flags for every country in the world into just over 400k - thank you TinyPNG ;) )
  • More detail retrieved and displayed, including timezone name, country, etc.
  • When doing a full "update", a text file is saved to your Desktop summarising any changes found.
  • General enhancement and tweaks.

PLEASE NOTE: Because this version stores its data substantially different to previous versions, it will create a new timezones.txt file with default cities. However, it will attempt to save your old timezones.txt file to your Desktop, so you should be able to rebuild your previous list without too much hassle. B)

 

A quick note about the flags: The workflow simply compares the retrieved name of the country and does a simple name match against the workflow's local repository of flag icons. From my testing, it's working very well, but I'd appreciate it if you'd report back if you find any countries that don't properly match a flag icon. Cheers.

 

----

 

31 March 2013  - UPDATE to v1.6

  • New feature: Custom lookups. Just keep typing a new place name after the tz keyword to look up the time in a place without saving it to your saved list.
  • Added support for phyllisstein's Alleyoop auto-updater.
  • [EXPERIMENTAL] - support for autocomplete for adding place names (timezone add). You'll need to add a keyword yourself to the script filter if you want to try it out. The reason I haven't enabled it by default is that I've found it kind of slow and I'm not sure it's actually an improvement over the current method. Let me know what you think.
    screenshot20130331at945.png [Add a keyword to this script filter if you'd like to try it out]
  • Novelty: Added (unofficial) Antarctica flag to flag repository. (Try tz south pole. ;)  )

----

 

2 April 2013 — UPDATE to v1.61

  • Small fix for Dutch (Netherlands) flag matching.

 

----

 

22 March 2014 — UPDATE to v1.7

  • City List now always shows in the same order. (Achieved by removing “uid” parameter.)
  • Removed Alleyoop updater.

Edited by CarlosNZ, 22 March 2014 - 09:27 AM.

  • Pedro Lobo, CarlosNZ, thec13 and 6 others like this
Twitter: @CarlosNZ | My Alfred Workflows: Carl's Geekzone

#2 David Ferguson

David Ferguson

    Alfred Guru

  • Staff
  • 1,845 posts
  • LocationHuntsville, AL

Posted 01 February 2013 - 12:39 PM

Cool idea, nicely done.


  • CarlosNZ likes this
Twitter: jdfwarrior | Blog: dferg.us

#3 CarlosNZ

CarlosNZ

    Advanced Member

  • Member
  • PipPipPip
  • 369 posts
  • LocationAuckland, New Zealand

Posted 02 February 2013 - 01:37 AM

I've realised that this fails on cities with non-integer offsets (eg. Adelaide, UTC+10.5 and New Delhi, +5.5). Will put out an update to fix this later this weekend.

#4 countdrachma

countdrachma

    Newbie

  • Member
  • Pip
  • 9 posts

Posted 03 February 2013 - 05:34 AM

That is a great workflow.  I will get great value out of this.  Thanks!


  • CarlosNZ likes this

#5 CarlosNZ

CarlosNZ

    Advanced Member

  • Member
  • PipPipPip
  • 369 posts
  • LocationAuckland, New Zealand

Posted 03 February 2013 - 09:20 AM

Thanks for the feedback guys.

 

I've updated it to 1.1 with the following changes:

  • Fixed the problem with cities with half-hour UTC offsets (eg. Adelaide—UTC+10.5, New Delhi—UTC+5.5
  • You can search the list of displayed cities (useful if you've got a lot) — just start typing after the "tz"
  • Hotkey to launch the list (set to Ctrl-Z by default)

B)


Twitter: @CarlosNZ | My Alfred Workflows: Carl's Geekzone

#6 jason.dour

jason.dour

    Newbie

  • Member
  • Pip
  • 3 posts

Posted 03 February 2013 - 05:14 PM

Nice workflow!  This will come in very handy at work.

 

One question, if you select one of the returned entries, Alfred learns that you "like" it more than other entries.

 

I'd prefer the order to remain static (time zone sorted, maybe?).  Is that possible by changing the output from the filter?  Do workflows have a way to tell Alfred to not learn the filter returns?



#7 CarlosNZ

CarlosNZ

    Advanced Member

  • Member
  • PipPipPip
  • 369 posts
  • LocationAuckland, New Zealand

Posted 03 February 2013 - 09:16 PM

One question, if you select one of the returned entries, Alfred learns that you "like" it more than other entries.

 

I'd prefer the order to remain static (time zone sorted, maybe?).  Is that possible by changing the output from the filter?  Do workflows have a way to tell Alfred to not learn the filter returns?

We don't have a lot of control over the order that Alfred displays the results because, yes, he does "learn" your preferred choices and prioritise them. But personally, I thought it worked in this case having your "favourite" places near the top of the list.

 

However, if you'd rather the list remained "neutral", you could try the following, assuming you're comfortable with editing the script within the workflow:

 

Open up the script file "timezone_list.sh" from the workflow folder. Find this line:

 

echo '<item uid="'$city'" arg="'$city'|'$city_time'|'$city_date'" valid="yes">

and try changing it to this:

 

echo '<item uid="'$RANDOM'" arg="'$city'|'$city_time'|'$city_date'" valid="yes">

That'll just generate a random value for the uid, which Alfred uses to learn your preferences, so it'll be different every time and there'll be no "preference" to learn. Should work, haven't actually tried it myself.

 

Thanks for the the feedback. In a future version I might make this a user-selectable option (although it'll still be fairly "hidden" as I don't imagine too many people would want to change it.)


Twitter: @CarlosNZ | My Alfred Workflows: Carl's Geekzone

#8 jason.dour

jason.dour

    Newbie

  • Member
  • Pip
  • 3 posts

Posted 03 February 2013 - 11:16 PM

Interesting.  I'll take a look at the script.

 

I understand most folks not liking it, but I work in a global corporation, and have team members around the world.  I have used world clocks for the last 12+ years because of this, and my brain just looks for things in the order in which they "always" are.  Just in the first hour of using the script off and on my brain kinda broke in quickly finding the name in the list.

 

But that's me.  8)  Thanks for the code ideas.



#9 CarlosNZ

CarlosNZ

    Advanced Member

  • Member
  • PipPipPip
  • 369 posts
  • LocationAuckland, New Zealand

Posted 03 February 2013 - 11:19 PM

Interesting.  I'll take a look at the script.

 

I understand most folks not liking it, but I work in a global corporation, and have team members around the world.  I have used world clocks for the last 12+ years because of this, and my brain just looks for things in the order in which they "always" are.  Just in the first hour of using the script off and on my brain kinda broke in quickly finding the name in the list.

 

But that's me.  8)  Thanks for the code ideas.

Let me know how it works out for you. And if you want complete control over the list order, you can probably manually edit the timezones.txt file. You'll find it at "~/Library/Application Support/Alfred 2/Workflow Data/carlosnz.timezones/timezones.txt". It should list them in that order initially, so combined with the $RANDOM uid, it'll probably keep them in your preferred order. Hopefully.


Twitter: @CarlosNZ | My Alfred Workflows: Carl's Geekzone

#10 Pedro Lobo

Pedro Lobo

    Member

  • Member
  • PipPip
  • 171 posts
  • LocationPortugal

Posted 03 February 2013 - 11:27 PM

Very nice. Had an idea to do something similar, saved me the trouble. Great implementation too! ;)
  • CarlosNZ likes this

#11 CarlosNZ

CarlosNZ

    Advanced Member

  • Member
  • PipPipPip
  • 369 posts
  • LocationAuckland, New Zealand

Posted 04 February 2013 - 01:05 AM

Small update to v1.2

- fixes to make "update" work better/properly/at all. :(


Twitter: @CarlosNZ | My Alfred Workflows: Carl's Geekzone

#12 judas

judas

    Member

  • Member
  • PipPip
  • 27 posts

Posted 11 February 2013 - 05:10 PM

Hi Carlos, I haven't been able to add new cities...I've even tried deleting and adding them back again with no luck. Is it all working on your side?



#13 Carlos-Sz

Carlos-Sz

    Advanced Member

  • Member
  • PipPipPip
  • 758 posts

Posted 11 February 2013 - 06:46 PM

Hi Carlos, I haven't been able to add new cities...I've even tried deleting and adding them back again with no luck. Is it all working on your side?

 

I’ve just tried to add São Paulo and Brasília with no luck.

 

Anyway, it’s a great workflow!



#14 raguay.customct

raguay.customct

    Advanced Member

  • Member
  • PipPipPip
  • 365 posts
  • LocationTak, Thailand

Posted 12 February 2013 - 02:47 AM

Hi, I like this workflow, but it is not adding my timezone: Tak, Thailand (GMT + 7). I tried just Bangkok, which is often well understood, but it still is not getting it.



#15 CarlosNZ

CarlosNZ

    Advanced Member

  • Member
  • PipPipPip
  • 369 posts
  • LocationAuckland, New Zealand

Posted 12 February 2013 - 07:07 AM

Hi guys, sorry for the trouble. Yes, it does appear there is some problem with updating/adding cities at the moment. It's probably something changed with the API. I'll look into it and get back to you ASAP. :(

 

Cheers.


Twitter: @CarlosNZ | My Alfred Workflows: Carl's Geekzone

#16 CarlosNZ

CarlosNZ

    Advanced Member

  • Member
  • PipPipPip
  • 369 posts
  • LocationAuckland, New Zealand

Posted 12 February 2013 - 11:07 PM

Yep, there's a change to the data returned by Wolfram Alpha. I'll fix this and release an update in a day or two.


  • judas likes this
Twitter: @CarlosNZ | My Alfred Workflows: Carl's Geekzone

#17 CarlosNZ

CarlosNZ

    Advanced Member

  • Member
  • PipPipPip
  • 369 posts
  • LocationAuckland, New Zealand

Posted 18 February 2013 - 01:52 AM

Okay updated version now available. (Updated initial post in this thread).

 

The version in the repo hasn't been updated yet, because it seems to be offline (is it like that for everyone?)

 

Let me know how it works for you. The data returned from Wolfram Alpha is now less consistent, and I've tried to account for every condition I've encountered, but it might have trouble with certain places, so let me know if you find any. For some reason, no Indian cities work anymore.

 

I'd like to find an alternative source for this info, so let me know if you've got any ideas. It needs to be flexible enough to interpret a city as input though.

 

Other improvements:

  • When doing a full "update", it won't fail the whole update if one city fails. A list of failed updates is saved to your Desktop.

 

Cheers,

 

C


Twitter: @CarlosNZ | My Alfred Workflows: Carl's Geekzone

#18 CarlosNZ

CarlosNZ

    Advanced Member

  • Member
  • PipPipPip
  • 369 posts
  • LocationAuckland, New Zealand

Posted 20 March 2013 - 06:40 AM

Hey guys,

 

I've updated this workflow to allow you to move the location of your saved city list (so you can put it in your Dropbox for syncing elsewhere, for example).

 

Keyword: timezone move

 

Cheers,

Carl.


Twitter: @CarlosNZ | My Alfred Workflows: Carl's Geekzone

#19 Jonathan Tom

Jonathan Tom

    Newbie

  • Member
  • Pip
  • 7 posts

Posted 22 March 2013 - 06:26 AM

Great workflow Carl, I'm having trouble adding timezones though - I've tried a couple of different cities without any success. Have there been any further changes to Wolfram's API? Are there known issues or am I doing something wrong?



#20 CarlosNZ

CarlosNZ

    Advanced Member

  • Member
  • PipPipPip
  • 369 posts
  • LocationAuckland, New Zealand

Posted 22 March 2013 - 09:06 AM

Great workflow Carl, I'm having trouble adding timezones though - I've tried a couple of different cities without any success. Have there been any further changes to Wolfram's API? Are there known issues or am I doing something wrong?

 

Thanks Jonathan. I think Wolfram might have been a bit flaky tonight. I just tried a few city additions, and the first few failed, but then it started working again. Have you tried again since posting? If it's still failing, what cities are you trying?


Twitter: @CarlosNZ | My Alfred Workflows: Carl's Geekzone



Also tagged with one or more of these keywords: workflows, time, script filter, utilities

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users