Skip to content

Commit

Permalink
Added support for datetime with zoneinfo tzinfo
Browse files Browse the repository at this point in the history
By converting input_datetime (string or datetime object) to a string before applying pandas' to_datetime, compatibility issues between pandas and zoneinfo are circumvented (pandas-dev/pandas#37654).
  • Loading branch information
dbkhout authored Jan 20, 2022
1 parent b66a796 commit 0ae12f8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/pywaterinfo/waterinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ def _parse_date(input_datetime, timezone="UTC"):
f"{timezone} is not a valid timezone string."
)

input_timestamp = pd.to_datetime(input_datetime)
input_timestamp = pd.to_datetime(str(input_datetime))

if input_timestamp.tz: # timestamp already contains tz info
return input_timestamp.tz_convert("CET").strftime("%Y-%m-%d %H:%M:%S")
Expand Down

0 comments on commit 0ae12f8

Please sign in to comment.