add support for milliseconds

This commit is contained in:
Aaron Raddon 2014-10-07 18:30:17 -07:00
parent 6b774e2c87
commit 97578a0e9c
2 changed files with 11 additions and 0 deletions

View File

@ -301,6 +301,12 @@ iterRunes:
} else {
return time.Time{}, err
}
} else if len(datestr) >= len("1384216367189") {
if miliSecs, err := strconv.ParseInt(datestr, 10, 64); err == nil {
return time.Unix(0, miliSecs*1000*1000), nil
} else {
return time.Time{}, err
}
} else {
if secs, err := strconv.ParseInt(datestr, 10, 64); err == nil {
return time.Unix(secs, 0), nil

View File

@ -223,6 +223,11 @@ func TestParse(t *testing.T) {
//u.Debug(ts.In(time.UTC).Unix(), ts.In(time.UTC))
assert.T(t, "2012-03-19 10:11:59 +0000 UTC" == fmt.Sprintf("%v", ts.In(time.UTC)))
ts, err = ParseAny("1384216367189")
assert.Tf(t, err == nil, "%v", err)
//u.Debug(ts.In(time.UTC).Unix(), ts.In(time.UTC))
assert.T(t, "2013-11-12 00:32:47.189 +0000 UTC" == fmt.Sprintf("%v", ts.In(time.UTC)))
}
// func TestWIP(t *testing.T) {