remove some pre-3.8 workarounds (#7671)

This commit is contained in:
Mike Fährmann
2025-06-17 12:56:47 +02:00
parent d0b1da0fa7
commit 6d928f3805
7 changed files with 8 additions and 37 deletions

View File

@@ -317,12 +317,7 @@ else:
def parse_datetime(date_string, format="%Y-%m-%dT%H:%M:%S%z", utcoffset=0):
"""Create a datetime object by parsing 'date_string'"""
try:
if format.endswith("%z") and date_string[-3] == ":":
# workaround for Python < 3.7: +00:00 -> +0000
ds = date_string[:-3] + date_string[-2:]
else:
ds = date_string
d = datetime.datetime.strptime(ds, format)
d = datetime.datetime.strptime(date_string, format)
o = d.utcoffset()
if o is not None:
# convert to naive UTC