From 934b3f146d3245bc533d3c44a1b4c99a8fefa068 Mon Sep 17 00:00:00 2001 From: Aaron Raddon Date: Sat, 24 Mar 2018 17:02:24 -0700 Subject: [PATCH] document new parseformat --- README.md | 5 +++++ dateparse/main.go | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/README.md b/README.md index 0d2188f..149ecec 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,11 @@ t, err := dateparse.ParseLocal("3/1/2014") // Equivalent to t, err := dateparse.ParseIn("3/1/2014", time.Local) + +// Return a string that represents the layout to parse the given date-time. +layout, err := dateparse.ParseFormat("May 8, 2009 5:57:51 PM") +> "Jan 2, 2006 3:04:05 PM" + ``` cli tool for testing dateformats diff --git a/dateparse/main.go b/dateparse/main.go index 78d4ba4..36bd5f6 100644 --- a/dateparse/main.go +++ b/dateparse/main.go @@ -30,8 +30,14 @@ func main() { datestr = flag.Args()[0] + layout, err := dateparse.ParseFormat(datestr) + if err != nil { + panic(err.Error()) + } + zonename, _ := time.Now().In(time.Local).Zone() fmt.Printf("\nYour Current time.Local zone is %v\n", zonename) + fmt.Printf("\nLayout String: dateparse.ParseFormat() => %v\n", layout) var loc *time.Location if timezone != "" { // NOTE: This is very, very important to understand