gusutabopb / aioinflux

Asynchronous Python client for InfluxDB
MIT License
159 stars 31 forks source link

Naive datetimes are being interpreted as local time #11

Closed miracle2k closed 6 years ago

miracle2k commented 6 years ago

Given the datetime datetime.datetime(2018, 4, 27, 20, 26, 38, 456123).

Before 65f986243cea98072da42f510905fddc116bc775, this resulted in a timestamp of 1524860798456123000 being sent (pd.Timestamp(x).value).

After, it results in 1524857198456123000 being sent (int(x.timestamp()) * 10 ** 9 + x.microsecond * 1000).

The first one interprets the time as UTC. The second one one interprets it as local time.

Not sure which one you prefer, just wanted to point out this (backwards-incompatible) change.

gusutabopb commented 6 years ago

Thanks for catching this bug!

This bug was introduced when making Pandas an optional dependency (#9). My stance is that naive datetimes should be assumed to be in UTC. See this note on the documentation. Now the behavior is consistent with how it was on >0.2.0, independent of whether or not Pandas is available.

Further reference:

gusutabopb commented 6 years ago

New release (v0.3.1) including this fix.