From 894fd9d30afd30309c07daff841d8083d3efe81b Mon Sep 17 00:00:00 2001 From: Ozzie Isaacs Date: Sat, 11 May 2024 18:21:03 +0200 Subject: [PATCH] get rid of apscheduler timezone warning --- cps/schedule.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cps/schedule.py b/cps/schedule.py index bf622b36..21c8d32a 100644 --- a/cps/schedule.py +++ b/cps/schedule.py @@ -69,9 +69,12 @@ def register_scheduled_tasks(reconnect=True): duration = config.schedule_duration # Register scheduled tasks - scheduler.schedule_tasks(tasks=get_scheduled_tasks(reconnect), trigger=CronTrigger(hour=start)) + timezone_info = datetime.datetime.now(datetime.timezone.utc).astimezone().tzinfo + scheduler.schedule_tasks(tasks=get_scheduled_tasks(reconnect), trigger=CronTrigger(hour=start, + timezone=timezone_info)) end_time = calclulate_end_time(start, duration) - scheduler.schedule(func=end_scheduled_tasks, trigger=CronTrigger(hour=end_time.hour, minute=end_time.minute), + scheduler.schedule(func=end_scheduled_tasks, trigger=CronTrigger(hour=end_time.hour, minute=end_time.minute, + timezone=timezone_info), name="end scheduled task") # Kick-off tasks, if they should currently be running