-
Notifications
You must be signed in to change notification settings - Fork 185
_time is None when setting timezone through DateHelper #454
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Also worth noting that trying to use Flux's timezone function doesn't seem to work with this client either, as it throws an error stating |
Hi @AaronCarton, thanks for using our client.
The #238 is supposed only for writes... I will update the from influxdb_client.client.util import date_utils
from influxdb_client.client.util.date_utils import DateHelper
import dateutil.parser
from dateutil import tz
def parse_date(date_string: str):
return dateutil.parser.parse(date_string).astimezone(tzlocal())
date_utils.date_helper = DateHelper()
date_utils.date_helper.parse_date = parse_date
How looks your query? The following code works for me: p = {"_start": datetime.timedelta(hours=-1),
"_location": "Prague",
"_desc": True,
"_floatParam": 25.1,
"_every": datetime.timedelta(minutes=5)
}
tables = query_api.query('''
import "timezone"
timezone.location(name: "America/Los_Angeles")
from(bucket:"my-bucket") |> range(start: _start)
|> filter(fn: (r) => r["_measurement"] == "my_measurement")
|> filter(fn: (r) => r["_field"] == "temperature")
|> filter(fn: (r) => r["location"] == _location and r["_value"] > _floatParam)
|> aggregateWindow(every: _every, fn: mean, createEmpty: true)
|> sort(columns: ["_time"], desc: _desc)
''', params=p) Regards |
Thanks, this fixes part of the problem! Although when I query data with I suspect this is because the |
It seems that |
Steps to reproduce:
feat: add possibility to specify default
timezone
for datetimes withouttzinfo
#238Expected behavior:
Query returns localized time/start/stop
Actual behavior:

Query returns None time/start/stop
Specifications:
The text was updated successfully, but these errors were encountered: