Simple script to query time zone data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#Show date and time in other time zones | |
ZONEINFO=/usr/share/zoneinfo/posix/ | |
FORMAT='%a %F %T' | |
query=$(echo $1 | tr '[:upper:]' '[:lower:]') | |
case "$query" in | |
au | aus ) | |
query=Melbourne | |
;; | |
lk | sl ) | |
query=Colombo | |
;; | |
uk | lon ) | |
query=London | |
;; | |
us | nyc ) | |
query=New_York | |
;; | |
*) | |
query=$1 | |
;; | |
esac | |
regex=".*${query}.*" | |
for zone in $(find $ZONEINFO -type f -iregex $regex) | |
do | |
d=$(TZ=$zone date +"$FORMAT") | |
printf "%-34s %23s\n" ${zone#$ZONEINFO} "$d" | |
done | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment