提交 6912568b 编写于 作者: X xywang

[TD-6408]<fix>: one second more than actual timestamp

上级 51849220
...@@ -272,26 +272,35 @@ void httpJsonTimestamp(JsonBuf* buf, int64_t t, int32_t timePrecision) { ...@@ -272,26 +272,35 @@ void httpJsonTimestamp(JsonBuf* buf, int64_t t, int32_t timePrecision) {
switch (timePrecision) { switch (timePrecision) {
case TSDB_TIME_PRECISION_MILLI: { case TSDB_TIME_PRECISION_MILLI: {
mod = ((t) % 1000 + 1000) % 1000;
if (t < 0 && mod != 0) {
t -= 1000;
}
quot = t / 1000; quot = t / 1000;
fractionLen = 5; fractionLen = 5;
format = ".%03" PRId64; format = ".%03" PRId64;
mod = ((t) % 1000 + 1000) % 1000;
break; break;
} }
case TSDB_TIME_PRECISION_MICRO: { case TSDB_TIME_PRECISION_MICRO: {
mod = ((t) % 1000000 + 1000000) % 1000000;
if (t < 0 && mod != 0) {
t -= 1000000;
}
quot = t / 1000000; quot = t / 1000000;
fractionLen = 8; fractionLen = 8;
format = ".%06" PRId64; format = ".%06" PRId64;
mod = ((t) % 1000000 + 1000000) % 1000000;
break; break;
} }
case TSDB_TIME_PRECISION_NANO: { case TSDB_TIME_PRECISION_NANO: {
mod = ((t) % 1000000000 + 1000000000) % 1000000000;
if (t < 0 && mod != 0) {
t -= 1000000000;
}
quot = t / 1000000000; quot = t / 1000000000;
fractionLen = 11; fractionLen = 11;
format = ".%09" PRId64; format = ".%09" PRId64;
mod = ((t) % 1000000000 + 1000000000) % 1000000000;
break; break;
} }
...@@ -319,26 +328,35 @@ void httpJsonUtcTimestamp(JsonBuf* buf, int64_t t, int32_t timePrecision) { ...@@ -319,26 +328,35 @@ void httpJsonUtcTimestamp(JsonBuf* buf, int64_t t, int32_t timePrecision) {
switch (timePrecision) { switch (timePrecision) {
case TSDB_TIME_PRECISION_MILLI: { case TSDB_TIME_PRECISION_MILLI: {
mod = ((t) % 1000 + 1000) % 1000;
if (t < 0 && mod != 0) {
t -= 1000;
}
quot = t / 1000; quot = t / 1000;
fractionLen = 5; fractionLen = 5;
format = ".%03" PRId64; format = ".%03" PRId64;
mod = ((t) % 1000 + 1000) % 1000;
break; break;
} }
case TSDB_TIME_PRECISION_MICRO: { case TSDB_TIME_PRECISION_MICRO: {
mod = ((t) % 1000000 + 1000000) % 1000000;
if (t < 0 && mod != 0) {
t -= 1000000;
}
quot = t / 1000000; quot = t / 1000000;
fractionLen = 8; fractionLen = 8;
format = ".%06" PRId64; format = ".%06" PRId64;
mod = ((t) % 1000000 + 1000000) % 1000000;
break; break;
} }
case TSDB_TIME_PRECISION_NANO: { case TSDB_TIME_PRECISION_NANO: {
mod = ((t) % 1000000000 + 1000000000) % 1000000000;
if (t < 0 && mod != 0) {
t -= 1000000000;
}
quot = t / 1000000000; quot = t / 1000000000;
fractionLen = 11; fractionLen = 11;
format = ".%09" PRId64; format = ".%09" PRId64;
mod = ((t) % 1000000000 + 1000000000) % 1000000000;
break; break;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册