Created
April 27, 2021 13:36
-
-
Save miy4/c209c264ab2ac8b409f8b3aec2bd8615 to your computer and use it in GitHub Desktop.
List all time zones and local times
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
#!/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