mirror of
https://github.com/araddon/dateparse.git
synced 2025-01-19 03:06:11 +08:00
Simplify date parsing, dont need ms etc
This commit is contained in:
parent
f0482b5ca2
commit
1bef41e8d2
64
parseany.go
64
parseany.go
@ -525,66 +525,10 @@ iterRunes:
|
|||||||
// 2006-01-02T15:04:05.9999-07:00
|
// 2006-01-02T15:04:05.9999-07:00
|
||||||
// 2006-01-02T15:04:05.999-07:00
|
// 2006-01-02T15:04:05.999-07:00
|
||||||
// 2006-01-02T15:04:05.99-07:00
|
// 2006-01-02T15:04:05.99-07:00
|
||||||
if len(datestr) == len("2006-01-02T15:04:05.999999999-07:00") {
|
if t, err := time.Parse("2006-01-02T15:04:05-07:00", datestr); err == nil {
|
||||||
if t, err := time.Parse("2006-01-02T15:04:05.999999999-07:00", datestr); err == nil {
|
return t, nil
|
||||||
return t, nil
|
} else {
|
||||||
} else {
|
return time.Time{}, err
|
||||||
return time.Time{}, err
|
|
||||||
}
|
|
||||||
} else if len(datestr) == len("2006-01-02T15:04:05.99999999-07:00") {
|
|
||||||
if t, err := time.Parse("2006-01-02T15:04:05.99999999-07:00", datestr); err == nil {
|
|
||||||
return t, nil
|
|
||||||
} else {
|
|
||||||
return time.Time{}, err
|
|
||||||
}
|
|
||||||
} else if len(datestr) == len("2006-01-02T15:04:05.9999999-07:00") {
|
|
||||||
if t, err := time.Parse("2006-01-02T15:04:05.9999999-07:00", datestr); err == nil {
|
|
||||||
return t, nil
|
|
||||||
} else {
|
|
||||||
return time.Time{}, err
|
|
||||||
}
|
|
||||||
} else if len(datestr) == len("2006-01-02T15:04:05.999999-07:00") {
|
|
||||||
if t, err := time.Parse("2006-01-02T15:04:05.999999-07:00", datestr); err == nil {
|
|
||||||
return t, nil
|
|
||||||
} else {
|
|
||||||
return time.Time{}, err
|
|
||||||
}
|
|
||||||
} else if len(datestr) == len("2006-01-02T15:04:05.99999-07:00") {
|
|
||||||
if t, err := time.Parse("2006-01-02T15:04:05.99999-07:00", datestr); err == nil {
|
|
||||||
return t, nil
|
|
||||||
} else {
|
|
||||||
return time.Time{}, err
|
|
||||||
}
|
|
||||||
} else if len(datestr) == len("2006-01-02T15:04:05.9999-07:00") {
|
|
||||||
if t, err := time.Parse("2006-01-02T15:04:05.9999-07:00", datestr); err == nil {
|
|
||||||
return t, nil
|
|
||||||
} else {
|
|
||||||
return time.Time{}, err
|
|
||||||
}
|
|
||||||
} else if len(datestr) == len("2006-01-02T15:04:05.999-07:00") {
|
|
||||||
if t, err := time.Parse("2006-01-02T15:04:05.999-07:00", datestr); err == nil {
|
|
||||||
return t, nil
|
|
||||||
} else {
|
|
||||||
return time.Time{}, err
|
|
||||||
}
|
|
||||||
} else if len(datestr) == len("2006-01-02T15:04:05.99-07:00") {
|
|
||||||
if t, err := time.Parse("2006-01-02T15:04:05.99-07:00", datestr); err == nil {
|
|
||||||
return t, nil
|
|
||||||
} else {
|
|
||||||
return time.Time{}, err
|
|
||||||
}
|
|
||||||
} else if len(datestr) == len("2006-01-02T15:04:05.9-07:00") {
|
|
||||||
if t, err := time.Parse("2006-01-02T15:04:05.9-07:00", datestr); err == nil {
|
|
||||||
return t, nil
|
|
||||||
} else {
|
|
||||||
return time.Time{}, err
|
|
||||||
}
|
|
||||||
} else if len(datestr) == len("2006-01-02T15:04:05-07:00") {
|
|
||||||
if t, err := time.Parse("2006-01-02T15:04:05-07:00", datestr); err == nil {
|
|
||||||
return t, nil
|
|
||||||
} else {
|
|
||||||
return time.Time{}, err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
case ST_DIGITDASHTZDIGIT:
|
case ST_DIGITDASHTZDIGIT:
|
||||||
// With a time-zone at end after Z
|
// With a time-zone at end after Z
|
||||||
|
Loading…
Reference in New Issue
Block a user