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
56
parseany.go
56
parseany.go
@ -525,67 +525,11 @@ iterRunes:
|
||||
// 2006-01-02T15:04:05.9999-07:00
|
||||
// 2006-01-02T15:04:05.999-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.999999999-07:00", datestr); err == nil {
|
||||
return t, nil
|
||||
} else {
|
||||
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:
|
||||
// With a time-zone at end after Z
|
||||
// 2006-01-02T15:04:05.999999999Z07:00
|
||||
|
Loading…
Reference in New Issue
Block a user