influxdb-rs/influxdb-rust

Incorrect calculation of Microseconds timestamp

amonin7 opened this issue · 1 comments

Right now, the conversion from influxdb::query::Timestamp::Microseconds to chrono::Datetime is incorrect:

            Timestamp::Microseconds(mis) => {
                let nanos = mis / 10000;
                Utc.timestamp_nanos(nanos.try_into().unwrap())
            }

In this case, nanos should be calculated by multiplying mis by MICROS_PER_NANO, which equals 1000.

p.s. If I understand correctly, this bug affects the correctness of timestamps stored in the influxdb and, therefore, if one uses microseconds precision to store the data - the time of the data in the database would be incorrect.

msrd0 commented

Interesting. Looks like this has been wrong since version 0.0.6, introduced in #41