From 6edb8c8318e0b2456fbdd1b67d22c874b584987e Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Mon, 11 Dec 2023 22:24:55 +0100 Subject: [PATCH] [#340] s/datetime.fromisoformat/dateutil.parser.isoparse/ We may receive JavaScript timestamps with non-standard `Z` suffix too. --- platypush/plugins/alarm/_model.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/platypush/plugins/alarm/_model.py b/platypush/plugins/alarm/_model.py index 401c92b7e4..d2af212650 100644 --- a/platypush/plugins/alarm/_model.py +++ b/platypush/plugins/alarm/_model.py @@ -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