A little Bash script to show information about world time zones. Because I love my colleagues abroad, but I constantly struggle to remember how many hours ahead (or behind) they are.
I am using the script on a Mac, but it should work on other systems too with little or no changes. Basically, it scans the zoneinfo database (more info) that most likely already exists on your computer to return the rows matching an input string.
For example, what's the time in Australia right now?
$ wdate australia
/Australia/Melbourne Tue 2021-10-12 20:47:48
/Australia/Queensland Tue 2021-10-12 19:47:48
/Australia/North Tue 2021-10-12 19:17:48
/Australia/Lord_Howe Tue 2021-10-12 20:47:48
/Australia/Adelaide Tue 2021-10-12 20:17:48
/Australia/Yancowinna Tue 2021-10-12 20:17:48
/Australia/Victoria Tue 2021-10-12 20:47:48
/Australia/Canberra Tue 2021-10-12 20:47:48
/Australia/Sydney Tue 2021-10-12 20:47:48
/Australia/ACT Tue 2021-10-12 20:47:48
/Australia/Eucla Tue 2021-10-12 18:32:48
/Australia/Brisbane Tue 2021-10-12 19:47:48
/Australia/Tasmania Tue 2021-10-12 20:47:48
/Australia/Hobart Tue 2021-10-12 20:47:48
/Australia/Perth Tue 2021-10-12 17:47:48
/Australia/South Tue 2021-10-12 20:17:48
/Australia/Lindeman Tue 2021-10-12 19:47:48
/Australia/Darwin Tue 2021-10-12 19:17:48
/Australia/West Tue 2021-10-12 17:47:48
/Australia/LHI Tue 2021-10-12 20:47:48
/Australia/NSW Tue 2021-10-12 20:47:48
/Australia/Broken_Hill Tue 2021-10-12 20:17:48
/Australia/Currie Tue 2021-10-12 20:47:48
Note: On my Mac, I found the zoneinfo database in this location:
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pytz/zoneinfo/
This path is needed for the script to work. You can customize it, of course—see below for how to do it.
Save the file above, e.g., as wdate, and then make it executable:
chmod +x wdate
If you don't know where to find zoneinfo data on your computer, just search for it. For example, on a Mac:
mdfind -name zoneinfo
That will give you a list of possible candidates.
Cite this blog post:
Comments via Github:
2021
2012
2010
2009