const now = moment(target.timestamp)
const before = moment(data.timestamp)
// now 가 before보다 몇시간 미래인가
const diff = now.diff(before, 'hour')
console.log(now)
console.log(before)
if (diff < 0) return -1
if (diff > 24) return 1
console.log(diff)
return 0
binary search를 위해 compare 함수를 구현했다.
아무리 개지랄을 해도 같은 id는 시간을 구별하지 못한다.
로그를 찍어봤다.
Moment<1970-01-20T16:01:26+09:00>
Moment<1970-01-20T15:58:33+09:00>
0
그렇다
moment는 기본적으로 unixtime을 ms 단위로 받는 것이다!
내가 쓰던 데이터는 s 단위였기 때문에 이 지랄이 난 것이었다.