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

Commit 5e99c09

Browse files
committed
[FIX] CI unit test failure - Test timezone in TestLineProtocol
1 parent bd10016 commit 5e99c09

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

influxdb/line_protocol.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,18 @@ def _convert_timestamp(timestamp, precision=None):
2525
if isinstance(_get_unicode(timestamp), text_type):
2626
timestamp = pd.Timestamp(timestamp)
2727

28-
if isinstance(timestamp, datetime):
28+
if isinstance(timestamp, datetime): # change to pandas.Timestamp
2929
if not timestamp.tzinfo:
3030
timestamp = pd.Timestamp(timestamp, tz='UTC')
31+
else:
32+
timestamp = pd.Timestamp(timestamp)
3133

3234
if isinstance(timestamp, pd._libs.tslib.Timestamp):
33-
if not timestamp.tzinfo:
35+
if not timestamp.tzinfo: # set to UTC for time since EPOCH
3436
timestamp = pd.Timestamp(timestamp, tz = 'UTC')
35-
37+
else:
38+
timestamp = timestamp.astimezone('UTC')
39+
3640
ns = (timestamp - EPOCH).value
3741
if precision is None or precision == 'n':
3842
return ns

0 commit comments

Comments
 (0)