Remove datetime hack used for python < 3.7

This commit is contained in:
Ivan Habunek 2023-06-30 11:08:22 +02:00
parent 3df8e2722a
commit da9931e5e5
No known key found for this signature in database
GPG Key ID: F5F0623FF5EBCB3D
1 changed files with 1 additions and 8 deletions

View File

@ -1,19 +1,12 @@
import math
import os
import re
from datetime import datetime, timezone
def parse_datetime(value):
"""Returns an aware datetime in local timezone"""
# In Python < 3.7, `%z` does not match `Z` offset
# https://docs.python.org/3.7/library/datetime.html#strftime-and-strptime-behavior
if value.endswith("Z"):
dttm = datetime.strptime(value, "%Y-%m-%dT%H:%M:%S.%fZ").replace(tzinfo=timezone.utc)
else:
dttm = datetime.strptime(value, "%Y-%m-%dT%H:%M:%S.%f%z")
dttm = datetime.strptime(value, "%Y-%m-%dT%H:%M:%S.%f%z")
# When running tests return datetime in UTC so that tests don't depend on
# the local timezone