Skip to content

Commit 9901c8e

Browse files
committed
BUG: Ensure datetime is time-zone aware
See influxdata/influxdb-client-python#73 We need a timezone aware datetime. Python 3.3+ uses .aztimezone(None) to convert to local timezone https://docs.python.org/3/library/datetime.html#datetime.datetime.astimezone
1 parent a40b034 commit 9901c8e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

gramex/data.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -2004,12 +2004,12 @@ def _influxdb_client(
20042004

20052005

20062006
def _timestamp_df(df, index_col="_time"):
2007-
now = datetime.now()
2007+
"""Add timestamp index by parsing `index_col` (default to now)."""
2008+
now = datetime.now().astimezone()
20082009
if index_col not in df:
20092010
df[index_col] = [now] * len(df)
20102011
else:
2011-
df[index_col] = pd.to_datetime(df[index_col], errors="coerce")
2012-
df[index_col].fillna(value=now, inplace=True)
2012+
df[index_col] = pd.to_datetime(df[index_col], errors="coerce").fillna(now)
20132013
return df.set_index(index_col)
20142014

20152015

0 commit comments

Comments
 (0)