From 6db71c51fcafe1cddc195615146f9739107515ae Mon Sep 17 00:00:00 2001 From: John Lancaster <32917998+jsl12@users.noreply.github.com> Date: Mon, 27 Jan 2025 17:09:02 -0600 Subject: [PATCH] parse_time now accepts datetimes in addition to strings --- appdaemon/scheduler.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/appdaemon/scheduler.py b/appdaemon/scheduler.py index 6e64c51ee..82d47ce66 100644 --- a/appdaemon/scheduler.py +++ b/appdaemon/scheduler.py @@ -939,7 +939,7 @@ async def parse_datetime( async def _parse_time( self, - time_str: str, + time_str: str | datetime, name: str | None = None, today: bool = False, days_offset: int = 0 @@ -947,6 +947,9 @@ async def _parse_time( sun = None offset = 0 + if isinstance(time_str, datetime): + return time_str + timedelta(days=days_offset) + # parse time with date if match := DATE_REGEX.match(time_str): kwargs = {k: int(v) for k, v in match.groupdict().items() if v is not None}