Skip to content

Commit 97043b0

Browse files
committed
Initial commit
1 parent ee3a914 commit 97043b0

File tree

2 files changed

+9194
-0
lines changed

2 files changed

+9194
-0
lines changed

β€Žcmd/t/main.goβ€Ž

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package main
2+
3+
import (
4+
"os"
5+
"fmt"
6+
"time"
7+
8+
"github.com/cv/t/codes"
9+
"strings"
10+
)
11+
12+
const layout = "15:04:05"
13+
14+
var clocksLow = []string{"πŸ•›", "πŸ•", "πŸ•‘", "πŸ•’", "πŸ•“", "πŸ•”", "πŸ••", "πŸ•–", "πŸ•—", "πŸ•˜", "πŸ•™", "πŸ•š",
15+
"πŸ•›", "πŸ•", "πŸ•‘", "πŸ•’", "πŸ•“", "πŸ•”", "πŸ••", "πŸ•–", "πŸ•—", "πŸ•˜", "πŸ•™", "πŸ•š"}
16+
var clocksHigh = []string{"πŸ•§", "πŸ•œ", "πŸ•", "πŸ•ž", "πŸ•Ÿ", "πŸ• ", "πŸ•‘", "πŸ•’", "πŸ•£", "πŸ•€", "πŸ•₯", "πŸ•¦",
17+
"πŸ•§", "πŸ•œ", "πŸ•", "πŸ•ž", "πŸ•Ÿ", "πŸ• ", "πŸ•‘", "πŸ•’", "πŸ•£", "πŸ•€", "πŸ•₯", "πŸ•¦",}
18+
19+
func main() {
20+
if len(os.Args) < 2 {
21+
fmt.Fprint(os.Stderr, "usage: t <IATA>...\n")
22+
os.Exit(-1)
23+
}
24+
25+
for _, i := range os.Args[1:] {
26+
show(i)
27+
}
28+
}
29+
30+
func show(iata string) {
31+
iata = strings.ToUpper(iata)
32+
33+
locName, found := codes.IATA[iata]
34+
if !found {
35+
fmt.Printf("%s: ??:??:?? (Unknown)\n", iata)
36+
return
37+
}
38+
loc, _ := time.LoadLocation(locName)
39+
now := time.Now().In(loc)
40+
41+
var emoji string
42+
if now.Minute() > 30 {
43+
emoji = clocksHigh[now.Hour()]
44+
} else {
45+
emoji = clocksLow[now.Hour()]
46+
}
47+
48+
fmt.Printf("%s: %s %s (%s)\n", iata, emoji, now.Format(layout), locName)
49+
}

0 commit comments

Comments
Β (0)