[#340] s/datetime.fromisoformat/dateutil.parser.isoparse/

We may receive JavaScript timestamps with non-standard `Z` suffix too.
This commit is contained in:
Fabio Manganiello 2023-12-11 22:24:55 +01:00
parent 6e7c5def2f
commit 6edb8c8318
Signed by: blacklight
GPG key ID: D90FBA7F76362774

View file

@ -7,6 +7,7 @@ from random import randint
from typing import Callable, Optional, Union
import croniter
from dateutil.parser import isoparse
from dateutil.tz import gettz
from platypush.context import get_bus, get_plugin
@ -171,7 +172,7 @@ class Alarm:
except (AttributeError, croniter.CroniterBadCronError):
try:
# If when is an ISO-8601 timestamp, parse it
t = datetime.datetime.fromisoformat(self.when).timestamp()
t = isoparse(self.when).timestamp()
except Exception as e:
raise AssertionError(f'Invalid alarm time {self.when}: {e}') from e