Skip to content

Instantly share code, notes, and snippets.

@rasher
Created January 1, 2025 19:13
Show Gist options
  • Save rasher/4dd00d452cb91d3d8737a6ce30349aa8 to your computer and use it in GitHub Desktop.
Save rasher/4dd00d452cb91d3d8737a6ce30349aa8 to your computer and use it in GitHub Desktop.
#!/bin/bash
cat <<eof |
PPG,Pago Pago,
HNL,Honolulu,
ANC,Anchorage,
YVR,Vancouver,
LAX,Los Angeles,
YEA,Edmonton,
DEN,Denver,
MEX,Mexico City,
CHI,Chicago,
NYC,New York,
SCL,Santiago,
YHZ,Halifax,
YYT,St. Johns,
RIO,Rio De Janeiro,America/Sao_Paulo
FEN,Fernando de Noronha,America/Noronha
RAI,Praia,Atlantic/Cape_Verde
UTC,UTC,UTC
LIS,Lisbon,
LON,London,
MAD,Madrid,
PAR,Paris,
ROM,Rome,
BER,Berlin,
STO,Stockholm,
ATH,Athens,
CAI,Cairo,
JRS,Jerusalem,
MOW,Moscow,
JED,Jeddah,Asia/Riyadh
THR,Tehran,
DXB,Dubai,
KBL,Kabul,
KHI,Karachi,
DEL,Delhi,Asia/Kolkata
KTM,Kathmandu,
DAC,Dhaka,
RGN,Yangon,
BKK,Bangkok,
SIN,Singapore,
HKG,Hong Kong,
BJS,Beijing,Asia/Shanghai
TPE,Taipei,
SEL,Seoul,
TYO,Tokyo,
ADL,Adelaide,
GUM,Guam,
SYD,Sydney,
NOU,Noumea,
WLG,Wellington,Pacific/Auckland
eof
(
while IFS=, read code city tz; do
if [ -z "$tz" ]; then
tz=$(timedatectl list-timezones |grep -i "$(echo $city |sed 's/\.//g;s/ /./g')" |head -n 1)
fi
if [ -z "$tz" ]; then
printf "Missing TZ: %s\n" "$city" >&2
else
printf "%s %s\n" "$code" "$(TZ=$tz date +%H:%M)"
fi
done
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment