mirror of
https://github.com/araddon/dateparse.git
synced 2024-11-10 11:51:54 +08:00
new date format
This commit is contained in:
parent
33ad15a3c7
commit
0dca814ad3
@ -137,6 +137,7 @@ iterRunes:
|
|||||||
}
|
}
|
||||||
case ST_DIGITDASHT: // starts digit then dash 02- then T
|
case ST_DIGITDASHT: // starts digit then dash 02- then T
|
||||||
// 2006-01-02T15:04:05Z07:00
|
// 2006-01-02T15:04:05Z07:00
|
||||||
|
// 2006-01-02T15:04:05
|
||||||
// 2006-01-02T15:04:05.999999999Z07:00
|
// 2006-01-02T15:04:05.999999999Z07:00
|
||||||
// 2006-01-02T15:04:05.999999999Z
|
// 2006-01-02T15:04:05.999999999Z
|
||||||
// 2006-01-02T15:04:05.99999999Z
|
// 2006-01-02T15:04:05.99999999Z
|
||||||
@ -158,6 +159,13 @@ iterRunes:
|
|||||||
} else {
|
} else {
|
||||||
return time.Time{}, err
|
return time.Time{}, err
|
||||||
}
|
}
|
||||||
|
} else if len(datestr) == len("2006-01-02T15:04:05") {
|
||||||
|
if t, err := time.Parse("2006-01-02T15:04:05", datestr); err == nil {
|
||||||
|
u.Errorf("wat? %v", t)
|
||||||
|
return t, nil
|
||||||
|
} else {
|
||||||
|
return time.Time{}, err
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// updated to include timestamps of different precisions
|
// updated to include timestamps of different precisions
|
||||||
if t, err := time.Parse("2006-01-02T15:04:05.999999999Z", datestr); err == nil {
|
if t, err := time.Parse("2006-01-02T15:04:05.999999999Z", datestr); err == nil {
|
||||||
|
@ -188,6 +188,11 @@ func TestParse(t *testing.T) {
|
|||||||
//u.Debug(ts.In(time.UTC).Unix(), ts.In(time.UTC))
|
//u.Debug(ts.In(time.UTC).Unix(), ts.In(time.UTC))
|
||||||
assert.T(t, "2009-08-13 05:15:09 +0000 UTC" == fmt.Sprintf("%v", ts.In(time.UTC)))
|
assert.T(t, "2009-08-13 05:15:09 +0000 UTC" == fmt.Sprintf("%v", ts.In(time.UTC)))
|
||||||
|
|
||||||
|
ts, err = ParseAny("2009-08-12T22:15:09")
|
||||||
|
assert.Tf(t, err == nil, "%v", err)
|
||||||
|
//u.Debug(ts.In(time.UTC))
|
||||||
|
assert.T(t, "2009-08-12 22:15:09 +0000 UTC" == fmt.Sprintf("%v", ts.In(time.UTC)))
|
||||||
|
|
||||||
ts, err = ParseAny("2014-04-26 17:24:37.3186369")
|
ts, err = ParseAny("2014-04-26 17:24:37.3186369")
|
||||||
assert.Tf(t, err == nil, "%v", err)
|
assert.Tf(t, err == nil, "%v", err)
|
||||||
//u.Debug(ts.In(time.UTC).Unix(), ts.In(time.UTC))
|
//u.Debug(ts.In(time.UTC).Unix(), ts.In(time.UTC))
|
||||||
|
Loading…
Reference in New Issue
Block a user