Skip to content

Instantly share code, notes, and snippets.

@miy4
Created April 27, 2021 13:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miy4/c209c264ab2ac8b409f8b3aec2bd8615 to your computer and use it in GitHub Desktop.
Save miy4/c209c264ab2ac8b409f8b3aec2bd8615 to your computer and use it in GitHub Desktop.
List all time zones and local times
#!/bin/bash
main() {
local -r now=$(date +%s)
find /usr/share/zoneinfo -type d -name right -prune \
-o -type d -name posix -prune \
-o -type f -print | while read -r f; do
if [[ $(head -c 4 "$f") != TZif ]]; then
continue
fi
tz="${f#/usr/share/zoneinfo/}"
printf '\033[32;1m%s\033[m\t%s\n' "$tz" "$(TZ=$tz LC_ALL=C date --date @"$now")"
done | sort -k 2 | column -t -s $'\t'
}
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment