Skip to content

Commit

Permalink
parse_time now accepts datetimes in addition to strings
Browse files Browse the repository at this point in the history
  • Loading branch information
jsl12 committed Jan 27, 2025
1 parent 9032078 commit 6db71c5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion appdaemon/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -939,14 +939,17 @@ 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
) -> dict:
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}
Expand Down

0 comments on commit 6db71c5

Please sign in to comment.