fix timezone logic bug for run once tasks

This commit is contained in:
wh1te909 2023-04-23 21:47:01 +00:00
parent 8f6056ae66
commit 9f95c57a09
1 changed files with 3 additions and 2 deletions

View File

@ -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)