Skip to content
This repository was archived by the owner on Oct 29, 2024. It is now read-only.

_convert_timestamp uses timezone information where it should not #250

Closed
wamdam opened this issue Oct 6, 2015 · 7 comments
Closed

_convert_timestamp uses timezone information where it should not #250

wamdam opened this issue Oct 6, 2015 · 7 comments
Labels

Comments

@wamdam
Copy link

wamdam commented Oct 6, 2015

When _convert_timestamp gets a datetime object with timezone data, it converts it to the system's default via timegm. Also when given a datetime object without timezone data, it assumes it to be the system's local timezone.

From this data, the timestamp is created. So the timestamp is always in local timezone.

This is wrong as influxdb requires UTC timestamps. This is especially important in my timezone (Europe/Berlin, currently +02:00) where current timestamps are inserted in influxdb's future and are not shown in queries.

The fix is to create timestamps from a datetime object that is converted to UTC first.

Our current workaround is to convert timestamps before calling line_protocol.make_lines like this:

time = int(mydatetimeobject.astimezone(pytz.UTC).replace(tzinfo=None).timestamp() * 1e9)

@aviau aviau added the bug label Oct 13, 2015
@aviau
Copy link
Collaborator

aviau commented Oct 13, 2015

Thank you for reporting the issue, I did not think of this! I'll label this as a bug.

@PaulKuiper
Copy link

Is this already solved? Sounds like a major bug.

@tomncooper
Copy link

This has caused me a serious headache in British Summer Time (GMT+1:00). The future timestamps lead to measurements being registered in InfluxDB so "SHOW MEASUREMENTS" and "SHOW SERIES" return results, but all "SELECT * FROM " will return success but will be empty. Very difficult to debug.

@rapport
Copy link

rapport commented Jul 1, 2016

I have been wondering why it looks like we have an hour delay in our live data. Sounds like something is not applying the daylight saving correctly!

tzonghao added a commit to tzonghao/influxdb-python that referenced this issue Sep 9, 2016
tzonghao added a commit to tzonghao/influxdb-python that referenced this issue Sep 9, 2016
@gdubicki
Copy link

MR is merged. Isn't the issue solved?

@sebito91
Copy link
Contributor

sebito91 commented Jul 7, 2017

@wamdam is this still an issue?

@aviau UPDATE REQUESTED

@wamdam
Copy link
Author

wamdam commented Jul 7, 2017

@sebito91 as you can see, I have solved this in my branch in october 2015 which is 2 years ago. I'll not try the new version, also because the project on my side has ended.

@aviau aviau closed this as completed Jul 7, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

7 participants