fix:precision problems in time conversion

This commit is contained in:
wangmm0220 2022-05-18 12:06:13 +08:00
parent 715aa50f4d
commit 5656c59261
1 changed files with 4 additions and 4 deletions

View File

@ -476,8 +476,8 @@ int64_t convertTimeFromPrecisionToUnit(int64_t time, int32_t fromPrecision, char
// the result of (NANOSECOND_PER_USEC/(double)factors[fromPrecision]) maybe a double // the result of (NANOSECOND_PER_USEC/(double)factors[fromPrecision]) maybe a double
switch (fromPrecision) { switch (fromPrecision) {
case TSDB_TIME_PRECISION_MILLI:{ case TSDB_TIME_PRECISION_MILLI:{
tmp /= 1000; tmp *= 1000;
time /= 1000; time *= 1000;
break; break;
} }
case TSDB_TIME_PRECISION_MICRO:{ case TSDB_TIME_PRECISION_MICRO:{
@ -486,8 +486,8 @@ int64_t convertTimeFromPrecisionToUnit(int64_t time, int32_t fromPrecision, char
break; break;
} }
case TSDB_TIME_PRECISION_NANO:{ case TSDB_TIME_PRECISION_NANO:{
tmp *= 1000; tmp /= 1000;
time *= 1000; time /= 1000;
break; break;
} }
} }