Skip to content

Commit 2089a33

Browse files
authored
docs: how to serialize the query results to custom timezone (#456)
1 parent 22a8707 commit 2089a33

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

influxdb_client/client/util/date_utils.py

+18-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,24 @@
88

99

1010
class DateHelper:
11-
"""DateHelper to groups different implementations of date operations."""
11+
"""
12+
DateHelper to groups different implementations of date operations.
13+
14+
If you would like to serialize the query results to custom timezone, you can use following code:
15+
16+
.. code-block:: python
17+
18+
from influxdb_client.client.util import date_utils
19+
from influxdb_client.client.util.date_utils import DateHelper
20+
import dateutil.parser
21+
from dateutil import tz
22+
23+
def parse_date(date_string: str):
24+
return dateutil.parser.parse(date_string).astimezone(tz.gettz('ETC/GMT+2'))
25+
26+
date_utils.date_helper = DateHelper()
27+
date_utils.date_helper.parse_date = parse_date
28+
"""
1229

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

0 commit comments

Comments
 (0)