From 9f95c57a0972fff1ff660c7a2a77be6bb04a23cd Mon Sep 17 00:00:00 2001 From: wh1te909 Date: Sun, 23 Apr 2023 21:47:01 +0000 Subject: [PATCH] fix timezone logic bug for run once tasks --- api/tacticalrmm/autotasks/models.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/api/tacticalrmm/autotasks/models.py b/api/tacticalrmm/autotasks/models.py index e27a19a5..4682259e 100644 --- a/api/tacticalrmm/autotasks/models.py +++ b/api/tacticalrmm/autotasks/models.py @@ -3,6 +3,7 @@ import random import string from contextlib import suppress from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union +from zoneinfo import ZoneInfo import pytz from django.core.cache import cache @@ -270,8 +271,8 @@ class AutomatedTask(BaseAuditModel): and self.task_type == TaskType.RUN_ONCE and self.run_asap_after_missed and agent - and self.run_time_date - < djangotime.now().astimezone(pytz.timezone(agent.timezone)) + and self.run_time_date.replace(tzinfo=ZoneInfo(agent.timezone)) + < djangotime.now().astimezone(ZoneInfo(agent.timezone)) ): self.run_time_date = ( djangotime.now() + djangotime.timedelta(minutes=5)