mirror of
https://github.com/araddon/dateparse.git
synced 2024-11-10 11:51:54 +08:00
Updated to include a few timestamps with different seconds precision
This commit is contained in:
parent
375d67e59f
commit
26dc426a1c
24
parseany.go
24
parseany.go
@ -125,6 +125,9 @@ iterRunes:
|
||||
case ST_DIGITDASHT: // starts digit then dash 02- then T
|
||||
// 2006-01-02T15:04:05Z07:00
|
||||
// 2006-01-02T15:04:05.999999999Z07:00
|
||||
// 2006-01-02T15:04:05.999999999Z
|
||||
// 2006-01-02T15:04:05.99999999Z
|
||||
// 2013-06-16T06:57:48.9999999Z
|
||||
if len(datestr) == len("2006-01-02T15:04:05Z07:00") {
|
||||
if t, err := time.Parse("2006-01-02T15:04:05Z07:00", datestr); err == nil {
|
||||
return t, nil
|
||||
@ -137,6 +140,27 @@ iterRunes:
|
||||
} else {
|
||||
return time.Time{}, err
|
||||
}
|
||||
} else {
|
||||
// updated to include timestamps of different precisions
|
||||
if t, err := time.Parse("2006-01-02T15:04:05.999999999Z", datestr); err == nil {
|
||||
return t, nil
|
||||
} else if t, err := time.Parse("2006-01-02T15:04:05.99999999Z", datestr); err == nil {
|
||||
return t, nil
|
||||
} else if t, err := time.Parse("2006-01-02T15:04:05.9999999Z", datestr); err == nil {
|
||||
return t, nil
|
||||
} else if t, err := time.Parse("2006-01-02T15:04:05.999999Z", datestr); err == nil {
|
||||
return t, nil
|
||||
} else if t, err := time.Parse("2006-01-02T15:04:05.99999Z", datestr); err == nil {
|
||||
return t, nil
|
||||
} else if t, err := time.Parse("2006-01-02T15:04:05.9999Z", datestr); err == nil {
|
||||
return t, nil
|
||||
} else if t, err := time.Parse("2006-01-02T15:04:05.999Z", datestr); err == nil {
|
||||
return t, nil
|
||||
} else if t, err := time.Parse("2006-01-02T15:04:05.99Z", datestr); err == nil {
|
||||
return t, nil
|
||||
} else {
|
||||
return time.Time{}, err
|
||||
}
|
||||
}
|
||||
case ST_DIGITSLASH: // starts digit then slash 02/
|
||||
// 2014/07/10 06:55:38.156283
|
||||
|
Loading…
Reference in New Issue
Block a user