diff --git a/README.md b/README.md index 2eea50b..1902a4f 100644 --- a/README.md +++ b/README.md @@ -11,14 +11,25 @@ Parse any date string without knowing format in advance. Uses a scanner to read ```go -// Normal parse +// Normal parse. If no recognized Timezone/Offset info +// exists in the datestring, it uses UTC. t, err := dateparse.ParseAny("3/1/2014") -// Parse with Location +// Parse with Location. If no recognized Timezone/Offset info +// exists in the datestring, it uses given location. +// IF there IS timezone/offset info it uses the given location +// info for any zone interpretation. That is, MST means one thing +// when using America/Denver and something else in other locations. denverLoc, _ := time.LoadLocation("America/Denver") - t, err := dateparse.ParseIn("3/1/2014", denverLoc) +// Set Location to time.Local. Same as ParseIn Location but +// Lazily uses a global variable for Location Info. +denverLoc, _ := time.LoadLocation("America/Denver") +// use time.Local global variable to store location +time.Local = denverLoc +t, err := dateparse.ParseLocal("3/1/2014") + ``` Extended example https://github.com/araddon/dateparse/blob/master/example/main.go diff --git a/parseany.go b/parseany.go index f42dea2..f16a888 100644 --- a/parseany.go +++ b/parseany.go @@ -87,12 +87,22 @@ func ParseAny(datestr string) (time.Time, error) { // ParseIn Given an unknown date format, detect the layout, // using given location, parse. +// +// If no recognized Timezone/Offset info exists in the datestring, it uses +// given location. IF there IS timezone/offset info it uses the given location +// info for any zone interpretation. That is, MST means one thing when using +// America/Denver and something else in other locations. func ParseIn(datestr string, loc *time.Location) (time.Time, error) { return parseTime(datestr, loc) } // ParseLocal Given an unknown date format, detect the layout, // using time.Local, parse. +// +// If no recognized Timezone/Offset info exists in the datestring, it uses +// given location. IF there IS timezone/offset info it uses the given location +// info for any zone interpretation. That is, MST means one thing when using +// America/Denver and something else in other locations. func ParseLocal(datestr string) (time.Time, error) { return parseTime(datestr, time.Local) }