mirror of
https://github.com/araddon/dateparse.git
synced 2025-01-19 19:26:09 +08:00
Bug fixes.
This commit is contained in:
parent
a8e238d5d1
commit
e654ac7b35
@ -178,7 +178,6 @@ func ParseIn(datestr string, loc *time.Location, opts ...ParserOption) (time.Tim
|
|||||||
// Equivalent to:
|
// Equivalent to:
|
||||||
//
|
//
|
||||||
// t, err := dateparse.ParseIn("3/1/2014", denverLoc)
|
// t, err := dateparse.ParseIn("3/1/2014", denverLoc)
|
||||||
//
|
|
||||||
func ParseLocal(datestr string, opts ...ParserOption) (time.Time, error) {
|
func ParseLocal(datestr string, opts ...ParserOption) (time.Time, error) {
|
||||||
p, err := parseTime(datestr, time.Local, opts...)
|
p, err := parseTime(datestr, time.Local, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -206,7 +205,6 @@ func MustParse(datestr string, opts ...ParserOption) time.Time {
|
|||||||
//
|
//
|
||||||
// layout, err := dateparse.ParseFormat("2013-02-01 00:00:00")
|
// layout, err := dateparse.ParseFormat("2013-02-01 00:00:00")
|
||||||
// // layout = "2006-01-02 15:04:05"
|
// // layout = "2006-01-02 15:04:05"
|
||||||
//
|
|
||||||
func ParseFormat(datestr string, opts ...ParserOption) (string, error) {
|
func ParseFormat(datestr string, opts ...ParserOption) (string, error) {
|
||||||
p, err := parseTime(datestr, nil, opts...)
|
p, err := parseTime(datestr, nil, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -2022,10 +2020,10 @@ func newParser(dateStr string, loc *time.Location, opts ...ParserOption) (*parse
|
|||||||
// allow the options to mutate the parser fields from their defaults
|
// allow the options to mutate the parser fields from their defaults
|
||||||
for _, option := range opts {
|
for _, option := range opts {
|
||||||
if err := option(p); err != nil {
|
if err := option(p); err != nil {
|
||||||
return nil, fmt.Sprintf("option error: %w", err)
|
return nil, fmt.Errorf("option error: %w", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return p
|
return p, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *parser) nextIs(i int, b byte) bool {
|
func (p *parser) nextIs(i int, b byte) bool {
|
||||||
|
Loading…
Reference in New Issue
Block a user