Skip to content

Commit 517eb8a

Browse files
committed
feat: Finished input parser
1 parent 3ccfc1f commit 517eb8a

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

main.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,17 @@ import (
1111
)
1212

1313
func writeDate(format string, timezone string) {
14-
log.Print(format)
15-
log.Print(timezone)
16-
_ = clipboard.WriteAll(format + timezone)
14+
15+
loc, e := time.LoadLocation(timezone)
16+
if e != nil {
17+
log.Fatal(e)
18+
}
19+
now := time.Now().In(loc)
20+
21+
timestamp := now.Format(format)
22+
clip := timestamp
23+
println(clip + " copied to clipboard")
24+
_ = clipboard.WriteAll(clip)
1725

1826
}
1927

@@ -29,7 +37,7 @@ func mainCliApp() error {
2937
Flags: []cli.Flag{
3038
&cli.StringFlag{
3139
Name: "format",
32-
Value: "YYYY-MM-DDTHH:MM:SSZ",
40+
Value: "2006-01-02T15:04:05Z07:00",
3341
Usage: "Timestamp format",
3442
},
3543
&cli.StringFlag{
@@ -43,6 +51,7 @@ func mainCliApp() error {
4351
format := c.String("format")
4452
timezone := c.String("timezone")
4553
writeDate(format, timezone)
54+
4655
return nil
4756
},
4857
}

0 commit comments

Comments
 (0)