提交 bd08e777 编写于 作者: S StoneT2000

Fixed time conversion bug

- Fixed bug when the least significant bits of timestamp may cause time to be converted to 0
- Fixed small display bug with time and sig figs.
上级 90a27ad7
......@@ -33,9 +33,6 @@ function convertTimestamp(data, num_of_rows, nbytes = 0, offset = 0, micro=false
let time = 0;
for (let i = currOffset; i < currOffset + nbytes; i++) {
queue.push(data[i]);
if (data[i] == 0) {
break;
}
}
for (let i = queue.length - 1; i >= 0; i--) {
time += queue[i] * Math.pow(16, i * 2);
......
......@@ -59,6 +59,12 @@ class TaosTimestamp extends Date {
pad = function(num) {
var norm = Math.floor(Math.abs(num));
return (norm < 10 ? '0' : '') + norm;
},
pad2 = function(num) {
var norm = Math.floor(Math.abs(num));
if (norm < 10) return '00' + norm;
if (norm < 100) return '0' + norm;
if (norm < 1000) return norm;
};
return this.getFullYear() +
'-' + pad(this.getMonth() + 1) +
......@@ -66,8 +72,8 @@ class TaosTimestamp extends Date {
' ' + pad(this.getHours()) +
':' + pad(this.getMinutes()) +
':' + pad(this.getSeconds()) +
'.' + pad(this.getMilliseconds()) +
'' + (this.microTime ? this.microTime.toFixed(3) : '').substr(2);
'.' + pad2(this.getMilliseconds()) +
'' + (this.microTime ? pad2(Math.round(this.microTime * 1000)) : '');
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册