Doc cleanup

This commit is contained in:
Aaron Raddon
2017-07-17 21:06:57 -07:00
parent 4fa7a8202c
commit 065d8139da
2 changed files with 106 additions and 66 deletions

View File

@@ -1,7 +1,9 @@
package main
import (
"flag"
"fmt"
"time"
"github.com/apcera/termtables"
"github.com/araddon/dateparse"
@@ -74,12 +76,32 @@ var examples = []string{
"1384216367189",
}
var (
timezone = ""
)
func main() {
flag.StringVar(&timezone, "timezone", "UTC", "Timezone aka `America/Los_Angeles` formatted time-zone")
flag.Parse()
if timezone != "" {
// NOTE: This is very, very important to understand
// time-parsing in go
loc, err := time.LoadLocation(timezone)
if err != nil {
panic(err.Error())
}
time.Local = loc
}
table := termtables.CreateTable()
table.AddHeaders("Input", "Parsed, and Output as %v")
for _, dateExample := range examples {
t := dateparse.MustParse(dateExample)
t, err := dateparse.ParseAny(dateExample)
if err != nil {
panic(err.Error())
}
table.AddRow(dateExample, fmt.Sprintf("%v", t))
}
fmt.Println(table.Render())