-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspydate
executable file
·39 lines (31 loc) · 861 Bytes
/
spydate
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/zsh -f
main() {
set -A spytimes
spytimes+=("Los Angeles" "America/Los_Angeles")
spytimes+=("New York" "America/New_York")
spytimes+=("UTC" "C")
spytimes+=("Ghana" "Africa/Accra")
spytimes+=("Nigeria" "Africa/Lagos")
spytimes+=("Stockholm" "Europe/Stockholm")
spytimes+=("Sri Lanka" "Asia/Colombo")
spytimes+=("Bangalore" "Asia/Kolkata")
spytimes+=("Bangladesh" "Asia/Dhaka")
local longest=0
# Find the longest name so that we can align time output nicely.
for name t in $spytimes; do
if [[ $longest -lt ${#name} ]]; then
longest=${#name}
fi
done
for name t in $spytimes; do
case $name in
UTC) decorate=1 ;;
*) decorate=0 ;;
esac
local attr=""
[[ $decorate -eq 1 ]] && echo -n "\x1b[1m"
printf "%${longest}s %s\n" "$name" "$(TZ=$t date --rfc-2822)"
[[ $decorate -eq 1 ]] && echo -n "\x1b[0m"
done
}
main