/home/alex/dev/worldclock.sh (1)
#!/bin/bash -
# ------------------------------------------------------------------------------
# worldclock.sh
# =============
#
# Scope Native
# Copyright (C) 2024 by RaySoft, Zurich, Switzerland
# License GNU General Public License (GPL) 2.0
# https://www.gnu.org/licenses/gpl2.txt
#
# ------------------------------------------------------------------------------
set -o 'noglob' -o 'nounset' -o 'pipefail' # -o 'xtrace' -o 'errexit'
# ------------------------------------------------------------------------------
CITIES=('Australia/Sydney' 'Europe/Zurich' 'Europe/London' 'America/New_York')
# ------------------------------------------------------------------------------
DATE=('/usr/local/bin/gdate')
PRINTF=('/usr/local/bin/gprintf')
# ------------------------------------------------------------------------------
for city in "${CITIES[@]}"; do
city_name="${city##*/}"; city_name="${city_name//_/ }"
"${PRINTF[@]}" '%-9s ' "${city_name}"
TZ="${city}" "${DATE[@]}" '+%H:%M %:z'
done
# ------------------------------------------------------------------------------
exit 0
Usage
~/dev/worldclock.sh
Output:
Sydney 06:00 +11:00
Zurich 20:00 +01:00
London 19:00 +00:00
New York 14:00 -05:00