{"modulePath":"github.com/araddon/dateparse","version":"v0.0.0-20210429162001-6b43995a97de","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package dateparse\n\nPackage dateparse parses date-strings without knowing the format in advance, using a fast lex based approach to eliminate shotgun attempts.  It leans towards US style dates when there is a conflict.\n\n## Variables\n\n```go\nvar (\n\t// ErrAmbiguousMMDD for date formats such as 04/02/2014 the mm/dd vs dd/mm are\n\t// ambiguous, so it is an error for strict parse rules.\n\tErrAmbiguousMMDD = fmt.Errorf(\"This date has ambiguous mm/dd vs dd/mm type format\")\n)\n```\n\n## Functions\n\n```go\nfunc MustParse(datestr string, opts ...ParserOption) time.Time\n```\nMustParse  parse a date, and panic if it can't be parsed.  Used for testing. Not recommended for most use-cases.\n\n```go\nfunc ParseAny(datestr string, opts ...ParserOption) (time.Time, error)\n```\nParseAny parse an unknown date format, detect the layout. Normal parse.  Equivalent Timezone rules as time.Parse(). NOTE:  please see readme on mmdd vs ddmm ambiguous dates.\n\n```go\nfunc ParseFormat(datestr string, opts ...ParserOption) (string, error)\n```\nParseFormat parse's an unknown date-time string and returns a layout string that can parse this (and exact same format) other date-time strings.\n\n\tlayout, err := dateparse.ParseFormat(\"2013-02-01 00:00:00\")\n\t// layout = \"2006-01-02 15:04:05\"\n\n```go\nfunc ParseIn(datestr string, loc *time.Location, opts ...ParserOption) (time.Time, error)\n```\nParseIn with Location, equivalent to time.ParseInLocation() timezone/offset rules.  Using location arg, if timezone/offset info exists in the datestring, it uses the given location rules for any zone interpretation. That is, MST means one thing when using America/Denver and something else in other locations.\n\n```go\nfunc ParseLocal(datestr string, opts ...ParserOption) (time.Time, error)\n```\nParseLocal Given an unknown date format, detect the layout, using time.Local, parse.\n\nSet Location to time.Local.  Same as ParseIn Location but lazily uses the global time.Local variable for Location argument.\n\n\tdenverLoc, _ := time.LoadLocation(\"America/Denver\")\n\ttime.Local = denverLoc\n\n\tt, err := dateparse.ParseLocal(\"3/1/2014\")\n\nEquivalent to:\n\n\tt, err := dateparse.ParseIn(\"3/1/2014\", denverLoc)\n\n```go\nfunc ParseStrict(datestr string, opts ...ParserOption) (time.Time, error)\n```\nParseStrict parse an unknown date format.  IF the date is ambigous mm/dd vs dd/mm then return an error. These return errors:   3.3.2014 , 8/8/71 etc\n\n## Types\n\n```go\ntype ParserOption func(*parser) error\n```\nParserOption defines a function signature implemented by options Options defined like this accept the parser and operate on the data within\n\n```go\nfunc PreferMonthFirst(preferMonthFirst bool) ParserOption\n```\nPreferMonthFirst is an option that allows preferMonthFirst to be changed from its default\n\n```go\nfunc RetryAmbiguousDateWithSwap(retryAmbiguousDateWithSwap bool) ParserOption\n```\nRetryAmbiguousDateWithSwap is an option that allows retryAmbiguousDateWithSwap to be changed from its default\n\n","path":"github.com/araddon/dateparse","name":"dateparse","synopsis":"Package dateparse parses date-strings without knowing the format in advance, using a fast lex based approach to eliminate shotgun attempts.","isRedistributable":true}
