jaroslawhartman / TimeZones-Alfred

Alfred Workflow
https://jhartman.pl/tag/time-zones/
Apache License 2.0
497 stars 21 forks source link

Sorting options for saved cities #9

Closed villeodell closed 5 years ago

villeodell commented 5 years ago

Hi there, love the workflow and appreciate the updates.

Have you ever considered adding options for sorting the saved cities? It would be really great to have options like:

Of course, one can accomplish it manually -- but it might be a nice enhancement to have this built in.

jaroslawhartman commented 5 years ago

Hi @villeodell

Thank you for these suggestions. Right now it's just sorting alphabetically.

Adding to the backlog, I will keep you updated via this ticket.

Thank you, Jarek

villeodell commented 5 years ago

I don't have a lot of experience with shell script but one way to achieve sorting might be to just use/store the UTC offset in timezones.txt and then use sort.

For example if timezones.txt included the UTC offset as the 6th element

Amsterdam|Netherlands|Europe/Amsterdam|NL|31|1
Chicago|United States|America/Chicago|US|1|-6
Helsinki|Finland|Europe/Helsinki|FI|358|3
Los Angeles|United States|America/Los_Angeles|US|1|-8
New York|United States|America/New_York|US|1|-5
Singapore|Singapore|Asia/Singapore|SG|65|8

Then perhaps you could simply do: East to West: sort -t'|' -k6 -n timezones.txt West to East: sort -t'|' -k6 -nr timezones.txt

And to extend that into the workflow change current line 114 of timezone_list.sh to: done < <(sort -t'|' -k6 "$sort_preference" "$timezone_file")

With $sort_preference being either -n (East to West) or -nr (West to East) depending on user settings

jaroslawhartman commented 5 years ago

one way to achieve sorting might be to just use/store the UTC offset in timezones.txt and then use sort

Very much indeed... Will take a look over the weekend.

Thank you, Jarek

jaroslawhartman commented 5 years ago

Enhancement #9 - favourite cities. Download release v2.3.

mymovie

jaroslawhartman commented 5 years ago

Added as v2.4 - see releases

jjarava commented 5 years ago

Hi, @jaroslawhartman

Just upgraded to v2.4 from the latest version, and while the ability to "star" cities is great, in the previous version if you hand-sorted the .txt file where the cities are stored, then that order would be kept.

For now, since you're sorting alphabetically I can sort-of regain that by changing the data file and adding a number to the name....

image

But that messes up the city search, as it's searching from the beginning of the name (could you do partial searching by the names? That'd be cool!)

So being able to sort either by not doing alphabetically but just keeping the order on the data file, or implementing east-to-west or west-to-east ordering (i.e., sorting based on the TZ as suggested above) would be great!

himat commented 5 years ago

@jjarava I had the same issue with the sorting not being good. So I removed the sorting entirely so that it just uses the order specified by the cities in your cities file. You can get it https://github.com/himat/TimeZones-Alfred.

jaroslawhartman commented 5 years ago

Fixed in version v2.12:

Added an option to enable or disable sorting:

Enable disable

When disabled, the order from timezones.txt is preserved:

Disabled

Disabled-list

Configuration file timezones.txt can be updated by selecting Edit option:

Screenshot 2019-08-14 at 14 51 07