gotz icon indicating copy to clipboard operation
gotz copied to clipboard

support sorting of timezones in output

Open jessefarinacci opened this issue 10 months ago • 1 comments

It'd be cool if there was a configuration option sort or similar that would sort all the timezones in the output, not just in the order that I list in my configuration file. (Trifold parameterized option: none, alpha, chrono maybe?)

For example, gotz -timezones 'America/New_York,Asia/Shanghai,Europe/London' will currently list the zones in order: Local, Asia, America, Europe, whereas gotz -timezones 'America/New_York,Asia/Shanghai,Europe/London' -sort chrono would future list zones in order: Asia, America, Local (my tz is us/ny), Europe.

I think this will make the user experience better as more areas of the screen will be contiguous available/unavailable shapes.

jessefarinacci avatar Feb 18 '25 15:02 jessefarinacci

Sounds good. I can try to look into it after looking into #19. I am currently on parental leave, so, my time is both more flexible and less flexible. 😹

Keep in mind that gotz' default behavior is to stick with any provided options. I.e., it will update the config any time an option is provided. Do you think that behavior will still suit your use-case?

merschformann avatar Feb 19 '25 00:02 merschformann

@jessefarinacci : I opened #24 as a draft for now. Can you test it / check it out and tell me what you think? ☺

You can install it via:

git checkout merschformann/tz-sorting
go install .

Edit: Addendum, I chose slightly different wording for the modes that felt a bit more intuitive to me. Let me know if I am off.

merschformann avatar Mar 02 '25 20:03 merschformann

Success! I tried a bunch of combos not shown below, I find it is working. Very helpful, thank you.


gotz on  merschformann/tz-sorting via 🐹 v1.24.0
❯ ./gotz -timezones 'UTC,America/Los_Angeles,America/Denver,America/Chicago,America/New_York,America/Puerto_Rico,America/Sao_Paulo,America/Nuuk,Atlantic/Cape_Verde' -sorting offset -sort-local-top true
                                                                                                    now v 23:38
Local              : Sun 02 Mar 2025 23:38 ███████████████████████████████▒▒▒▒▒▒▒▒▒▒▒                   |                                  ▒▒▒▒▒▒▒▒▒▒▒███████████████
America/Los_Angeles: Sun 02 Mar 2025 20:38 ███████████████████████████████████████████████▒▒▒▒▒▒▒▒▒▒▒   |                                                   ▒▒▒▒▒▒▒▒▒
America/Denver     : Sun 02 Mar 2025 21:38 ██████████████████████████████████████████▒▒▒▒▒▒▒▒▒▒▒        |                                             ▒▒▒▒▒▒▒▒▒▒▒████
America/Chicago    : Sun 02 Mar 2025 22:38 ████████████████████████████████████▒▒▒▒▒▒▒▒▒▒▒              |                                        ▒▒▒▒▒▒▒▒▒▒▒█████████
America/New_York   : Sun 02 Mar 2025 23:38 ███████████████████████████████▒▒▒▒▒▒▒▒▒▒▒                   |                                  ▒▒▒▒▒▒▒▒▒▒▒███████████████
America/Puerto_Rico: Mon 03 Mar 2025 00:38 █████████████████████████▒▒▒▒▒▒▒▒▒▒▒                         |                             ▒▒▒▒▒▒▒▒▒▒▒████████████████████
America/Sao_Paulo  : Mon 03 Mar 2025 01:38 ████████████████████▒▒▒▒▒▒▒▒▒▒▒                              |                       ▒▒▒▒▒▒▒▒▒▒▒██████████████████████████
America/Nuuk       : Mon 03 Mar 2025 02:38 ██████████████▒▒▒▒▒▒▒▒▒▒▒                                    |                  ▒▒▒▒▒▒▒▒▒▒▒███████████████████████████████
Atlantic/Cape_Verde: Mon 03 Mar 2025 03:38 █████████▒▒▒▒▒▒▒▒▒▒▒                                         |            ▒▒▒▒▒▒▒▒▒▒▒█████████████████████████████████████
UTC                : Mon 03 Mar 2025 04:38 ███▒▒▒▒▒▒▒▒▒▒▒                                               |       ▒▒▒▒▒▒▒▒▒▒▒██████████████████████████████████████████
^             ^                ^               ^               ^                ^               ^                ^
12            15               18              21              0                3               6                9

I'll let GitHub close the issue when the branch is merged mainline. Thanks again!

jessefarinacci avatar Mar 03 '25 04:03 jessefarinacci