Skip to content

Instantly share code, notes, and snippets.

@chanux
Created March 12, 2012 05:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chanux/2020097 to your computer and use it in GitHub Desktop.
Save chanux/2020097 to your computer and use it in GitHub Desktop.
Simple script to query time zone data
#!/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