new date format

This commit is contained in:
Aaron Raddon 2015-06-25 14:09:39 -07:00
parent 33ad15a3c7
commit 0dca814ad3
2 changed files with 13 additions and 0 deletions

View File

@ -137,6 +137,7 @@ iterRunes:
}
case ST_DIGITDASHT: // starts digit then dash 02- then T
// 2006-01-02T15:04:05Z07:00
// 2006-01-02T15:04:05
// 2006-01-02T15:04:05.999999999Z07:00
// 2006-01-02T15:04:05.999999999Z
// 2006-01-02T15:04:05.99999999Z
@ -158,6 +159,13 @@ iterRunes:
} else {
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 {
// updated to include timestamps of different precisions
if t, err := time.Parse("2006-01-02T15:04:05.999999999Z", datestr); err == nil {

View File

@ -188,6 +188,11 @@ func TestParse(t *testing.T) {
//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)))
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")
assert.Tf(t, err == nil, "%v", err)
//u.Debug(ts.In(time.UTC).Unix(), ts.In(time.UTC))