irm-kmi-ha/custom_components/irm_kmi/irm_kmi_api/utils.py

8 lines
204 B
Python

from datetime import timedelta
def next_weekday(current, weekday):
days_ahead = weekday - current.weekday()
if days_ahead < 0:
days_ahead += 7
return current + timedelta(days_ahead)