Skip to content

docs: how to serialize the query results to custom timezone #456

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

Merged
merged 2 commits into from
Jun 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion influxdb_client/client/util/date_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,24 @@


class DateHelper:
"""DateHelper to groups different implementations of date operations."""
"""
DateHelper to groups different implementations of date operations.

If you would like to serialize the query results to custom timezone, you can use following code:

.. code-block:: python

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(tz.gettz('ETC/GMT+2'))

date_utils.date_helper = DateHelper()
date_utils.date_helper.parse_date = parse_date
"""

def __init__(self, timezone: datetime.tzinfo = tz.utc) -> None:
"""
Expand Down