From 6567e51a00f0089c09c90746ca7149781b447a27 Mon Sep 17 00:00:00 2001 From: Ross Spencer Date: Tue, 10 Oct 2023 17:32:50 +0100 Subject: [PATCH] Use correct UTC settings for crontab --- rq_scheduler/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rq_scheduler/utils.py b/rq_scheduler/utils.py index c34ab02..6e9cd99 100644 --- a/rq_scheduler/utils.py +++ b/rq_scheduler/utils.py @@ -2,7 +2,7 @@ import crontab import dateutil.tz -from datetime import datetime, timedelta +from datetime import datetime, timedelta, timezone import logging from rq.logutils import ColorizingStreamHandler @@ -23,7 +23,7 @@ def to_unix(dt): def get_next_scheduled_time(cron_string, use_local_timezone=False): """Calculate the next scheduled time by creating a crontab object with a cron string""" - now = datetime.now() + now = datetime.now(timezone.utc) cron = crontab.CronTab(cron_string) next_time = cron.next(now=now, return_datetime=True) tz = dateutil.tz.tzlocal() if use_local_timezone else dateutil.tz.UTC