-
-
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 |
👍
Inspired by oz/tz, updated to include a list of recent/upcoming hours in each tz:
December 2021 January 2022 February 2022
Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa
1 2 3 4 1 1 2 3 4 5
5 6 7 8 9 10 11 2 3 4 5 6 7 8 6 7 8 9 10 11 12
12 13 14 15 16 17 18 9 10 11 12 13 14 15 13 14 15 16 17 18 19
19 20 21 22 23 24 25 16 17 18 19 20 21 22 20 21 22 23 24 25 26
26 27 28 29 30 31 23 24 25 26 27 28 29 27 28
30 31
08:48 Mon Sydney 02 03 04 05 06 07 08 09 10 11 12 13 14 AEDT (UTC+1100)
06:48 Mon Japan 00 01 02 03 04 05 06 07 08 09 10 11 12 JST (UTC+0900)
05:48 Mon China 23 00 01 02 03 04 05 06 07 08 09 10 11 CST (UTC+0800)
01:48 Mon Reunion 19 20 21 22 23 00 01 02 03 04 05 06 07 +04 (UTC+0400)
22:48 Sun France 16 17 18 19 20 21 22 23 00 01 02 03 04 CET (UTC+0100)
21:48 Sun London 15 16 17 18 19 20 21 22 23 00 01 02 03 GMT (UTC+0000)
21:48 Sun UTC 15 16 17 18 19 20 21 22 23 00 01 02 03 UTC (UTC+0000)
16:48 Sun Boston 10 11 12 13 14 15 16 17 18 19 20 21 22 EST (UTC-0500)
15:48 Sun Chicago 09 10 11 12 13 14 15 16 17 18 19 20 21 CST (UTC-0600)
14:48 Sun Edmonton 08 09 10 11 12 13 14 15 16 17 18 19 20 MST (UTC-0700)
13:48 Sun Vancouver 07 08 09 10 11 12 13 14 15 16 17 18 19 PST (UTC-0800)
(current day and hour are boldfaced, but that doesn't seem to survive cut/paste)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sample output: