Fix incorrect timeformatting

This commit is contained in:
Stijn De Clercq 2021-11-29 22:12:53 +01:00
parent dd60840576
commit 8350b01d85
2 changed files with 7 additions and 2 deletions

View file

@ -157,7 +157,12 @@ def fromString(timeString: str, formatString="%d/%m/%Y", tzinfo=pytz.timezone("E
"""
Constructs a datetime object from an input string
"""
return datetime.datetime.strptime(timeString, formatString).replace(tzinfo=tzinfo)
dt = datetime.datetime.strptime(timeString, formatString)
if tzinfo is not None:
dt = dt.replace(tzinfo=tzinfo)
return dt
def fromArray(data: List[int]) -> datetime: