Last active
November 11, 2018 04:32
-
-
Save didenko/d5e3c5f143d9e9eb7b6d37f09bade97e to your computer and use it in GitHub Desktop.
Cross-timezone calculations
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
function timein () | |
{ | |
[ "${#}" -lt 3 ] && { | |
echo 'timein <dest loc> [when] <src loc> [is] <src time>' 1>&2 | |
echo -e 'e.g.:\ntimein America/Chicago when Europe/Berlin is tomorrow 14:30' 1>&2 | |
echo -e 'or:\ntimein Asia/Ho_Chi_Minh America/New_York 2019/01/02 08:00' 1>&2 | |
return 1 | |
} | |
dest=${1}; shift | |
[ "${1}" == "when" ] && shift | |
src=${1}; shift | |
[ "${1}" == "is" ] && shift | |
on=${*} | |
TZ=${dest} date --date="TZ=\"${src}\" ${on}" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment