diff --git a/core/http.go b/core/http.go index 5aadbb346..0803b4d2c 100644 --- a/core/http.go +++ b/core/http.go @@ -323,17 +323,23 @@ type JsonObject map[string]interface{} // func bitmaps(frame string, obj JsonObject) chan uint64 { c := make(chan uint64) - const shortForm = "2006-01-02 15:04:01" go func() { + const shortFormT = "2006-01-02T15:04:05" + const shortFormS = "2006-01-02 15:04:05" t := float64(obj["bitmap_id"].(float64)) base_id := uint64(t) if strings.HasSuffix(frame, ".t") { timestamp := obj["timestamp"].(string) + shortForm := shortFormS + if strings.Contains(timestamp, "T") { + shortForm = shortFormT + } atime, _ := time.Parse(shortForm, timestamp) for _, id := range index.GetTimeIds(base_id, atime, index.YMDH) { + log.Println(id) c <- id } } else { diff --git a/index/timeframe_test.go b/index/timeframe_test.go index fb8814967..77125e1b1 100644 --- a/index/timeframe_test.go +++ b/index/timeframe_test.go @@ -21,20 +21,24 @@ func getTime(id uint64, s string) { } func TestDemo(t *testing.T) { Convey("Test ID", t, func() { - getTime(uint64(666), "2014-01-01 00:00") - getTime(uint64(666), "2014-02-01 00:00") - getTime(uint64(666), "2014-03-01 00:00") - getTime(uint64(666), "2014-04-01 00:00") - getTime(uint64(666), "2014-04-02 00:00") - getTime(uint64(666), "2014-04-03 00:00") - getTime(uint64(666), "2014-04-04 00:00") - getTime(uint64(666), "2014-04-05 00:00") - getTime(uint64(666), "2014-05-01 00:00") - getTime(uint64(666), "2014-06-01 00:00") + getTime(uint64(1), "2014-08-11 14:00") So(1, ShouldEqual, 1) }) } func TestTimeFrame(t *testing.T) { + Convey("Test 1H", t, func() { + const shortForm = "2006-01-02 15:04" + t1, _ := time.Parse(shortForm, "2014-08-11 14:00") + t2, _ := time.Parse(shortForm, "2014-08-11 16:00") + m := GetRange(t1, t2, uint64(1)) + getTime(uint64(1), "2014-08-11 14:00") + spew.Dump(m) + + So(len(m), ShouldEqual, 1) + }) + if true { + return + } //print get_YMD_id(2014,3,28,1234) Convey("Test ID", t, func() {