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.
This commit is contained in:
parent
90a27ad7fd
commit
bd08e77705
|
@ -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)) : '');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue