tz icon indicating copy to clipboard operation
tz copied to clipboard

List known timezones

Open donpdonp opened this issue 3 years ago • 5 comments

The biggest problem I had with getting started with TZ was populating TZ_LIST. The screenshot showed entries like "-07" and "GMT" but the TZ_LIST only understands the full/city_name style. So it'd be helpful if tz had a flag to dump the list, so I could at least grep for relevant entries. Ideally there'd be a UI where I can search and add timezones that tz will remember (~/.config/tz) for next launch.

donpdonp avatar Mar 23 '21 16:03 donpdonp

@donpdonp This would just be repeating name of the zoneinfo files on your hard drive. Try something like this to find them:

  find /usr/share/zoneinfo/posix -type 

If that doesn't get any results, try locate zoneinfo.

The docs could be patched with a tip like this, or to recommend a website where they can be looked up.

markstos avatar Mar 23 '21 17:03 markstos

I agree, though one could say the 'tz' tool is repeating information the computer already knows. Finding the zonefile list is tricky and thats something else tz could make easier. https://stackoverflow.com/questions/40120056/get-a-list-of-valid-time-zones-in-go

donpdonp avatar Mar 23 '21 18:03 donpdonp

This part can easily be improved, but I haven't dived yet into Go's support for tz. AFAIK it fishes the data from the OS but can (does?) also embed the whole tz database. I hope the db can be browsed at runtime to improve the current DIY state.

The point is, the program should assist you into picking a list of timezones effortlessly.

oz avatar Mar 24 '21 02:03 oz

I've been pondering this myself for a bit so dove in and created this https://gist.github.com/runeimp/d3a36b68521e21f4fc50e25771ab4a5c which may help. 😄

runeimp avatar Mar 25 '21 02:03 runeimp

You might also find https://github.com/tkuchiki/go-timezone and https://github.com/tkuchiki/timezones useful

runeimp avatar Mar 25 '21 03:03 runeimp

In v0.6.2, tz added the option to list all the time zones that the system knows about:

  • with tz -list, or
  • interactively with tz -list | fzf (requires fzf), or
  • even with a basic filtering tz -list calcutta.

I consider that this is enough to close this issue. ✔️

I know that some users would also like to use tz to find the time zone of all the cities in the world. It could mean embedding a large database of cities, agreement on a list of significant cities, or even online search -- which some people may not want -- etc.

I consider that slightly out of scope, but YMMV. 😄

🔮 In the future, I may also add a different "view" to tz: to add/remove time zones to a running "tz" instance, but that's not high on my list of priorities TBH.

oz avatar Jan 16 '23 19:01 oz