-
-
Save gosko/fc36193bf56353dfacc60ad057f9e7e4 to your computer and use it in GitHub Desktop.
dt - display current date/time in various time zones
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 | |
# | |
# dt: display useful date/time info incl current time in various time zones | |
# | |
# Any optional extra args are passed along to 'date'. | |
# | |
# usage examples: | |
# | |
# $ dt | |
# $ dt --date '3 hours ago' | |
# | |
# Hour listing inspired by https://github.com/oz/tz | |
# | |
show () { | |
tz=$1; shift | |
place=$1; shift | |
echo -n "$(TZ=$tz date +'%H:%M %a' "$@") " | |
printf "%-9s " $place | |
hour=$(TZ=$tz date +%k "$@") | |
for i in {-6..6}; do | |
if [ $i -eq 0 ]; then echo -n $bold; fi | |
printf "%02d" $((($hour+$i+24)%24)) | |
if [ $i -eq 0 ]; then echo -n $sgr0; fi | |
echo -n " " | |
done | |
echo " $(TZ=$tz date +'%4Z (UTC%z)' "$@")" | |
} | |
bold=$(tput bold) | |
sgr0=$(tput sgr0) | |
echo | |
/usr/bin/cal -3 | |
echo | |
show Australia/Sydney Sydney "$@" | |
show Asia/Tokyo Japan "$@" | |
show Asia/Shanghai China "$@" | |
show Indian/Reunion Reunion "$@" | |
show Europe/Paris France "$@" | |
show Europe/London London "$@" | |
show UTC UTC "$@" | |
show US/Eastern Boston "$@" | |
show US/Central Chicago "$@" | |
show Canada/Mountain Edmonton "$@" | |
show Canada/Pacific Vancouver "$@" | |
echo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Inspired by oz/tz, updated to include a list of recent/upcoming hours in each tz:
(current day and hour are boldfaced, but that doesn't seem to survive cut/paste)