Convert given time to multiple timezones. Let people know in other TZs when you intend to perform some action.
➜ ~ btz 2100
04:00 HKT | 22:00 CEST | 21:00 BST
Find more timezones. On MacOS:
ls /usr/share/zoneinfo
Update timezones in btz!
| Broadcast Time Zone |
| #!/bin/sh | |
| # Convert given time to multiple timezones. | |
| # Let people know in other TZs when you intend | |
| # to perform some action. | |
| timezones=('Asia/Hong_Kong' 'Europe/Warsaw' 'Europe/London') | |
| separator=' | ' | |
| time_format="%H:%M %Z" | |
| local_date_now=$(date +%s) | |
| local_date_future=$(date -j $1 +%s) | |
| diff=$(expr $((local_date_future-local_date_now))) | |
| [ $diff -lt 0 ] && adjust_prefix="" || adjust_prefix="+" | |
| results=() | |
| for tz in ${timezones[@]} | |
| do | |
| results+=("$(TZ=$tz date -v $adjust_prefix$diff"S" +"$time_format")") | |
| done | |
| output=$(printf "${separator}%s" "${results[@]}") | |
| output=${output:${#separator}} | |
| echo $output |
A tip: you can slap this inside your
*rcfile and use it as shell function.btz() { // body of above Gist }