From 0ae12f81c402ad4b49bd2d9b718aa734d3253d13 Mon Sep 17 00:00:00 2001 From: dbkhout <70980044+dbkhout@users.noreply.github.com> Date: Thu, 20 Jan 2022 13:05:12 +0100 Subject: [PATCH] Added support for datetime with zoneinfo tzinfo By converting input_datetime (string or datetime object) to a string before applying pandas' to_datetime, compatibility issues between pandas and zoneinfo are circumvented (https://github.com/pandas-dev/pandas/issues/37654). --- src/pywaterinfo/waterinfo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pywaterinfo/waterinfo.py b/src/pywaterinfo/waterinfo.py index 3308026..8bb4bd1 100755 --- a/src/pywaterinfo/waterinfo.py +++ b/src/pywaterinfo/waterinfo.py @@ -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")