mirror of
https://github.com/araddon/dateparse.git
synced 2024-12-05 05:30:13 +08:00
improve error output formatting
This commit is contained in:
parent
6135c1994e
commit
0963c6f518
@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/apcera/termtables"
|
||||
@ -32,7 +33,7 @@ func main() {
|
||||
|
||||
layout, err := dateparse.ParseFormat(datestr)
|
||||
if err != nil {
|
||||
panic(err.Error())
|
||||
fatal(err)
|
||||
}
|
||||
|
||||
zonename, _ := time.Now().In(time.Local).Zone()
|
||||
@ -44,7 +45,7 @@ func main() {
|
||||
// time-parsing in go
|
||||
l, err := time.LoadLocation(timezone)
|
||||
if err != nil {
|
||||
panic(err.Error())
|
||||
fatal(err)
|
||||
}
|
||||
loc = l
|
||||
zonename, _ := time.Now().In(l).Zone()
|
||||
@ -77,10 +78,6 @@ func main() {
|
||||
fmt.Println(table.Render())
|
||||
}
|
||||
|
||||
func stuff() (string, string) {
|
||||
return "more", "stuff"
|
||||
}
|
||||
|
||||
type parser func(datestr string, loc *time.Location, utc bool) string
|
||||
|
||||
func parseLocal(datestr string, loc *time.Location, utc bool) string {
|
||||
@ -127,3 +124,8 @@ func parseStrict(datestr string, loc *time.Location, utc bool) string {
|
||||
}
|
||||
return t.String()
|
||||
}
|
||||
|
||||
func fatal(err error) {
|
||||
fmt.Printf("fatal: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user