Closed
Description
Describe the bug
OnceTaskType shows in Admin UI in the field "Schedule" raw datetime from Database
But in my case - my timezone is UTC+3
My Database store datetime in UTC timezone
So, it means that for task at 23:00 in the filed "Schedule" I see "20:00", cause this time is stored in DB.
To Reproduce
Steps to reproduce the behavior:
- Be sure, that you have different timezones: in the Django, and stored Datetime in Database.
- Create a task with type OnceTaskType
- Go to page /scheduler/task/ in admin UI
- Check Datetime for Run once in Column "Schedule"
- If you have differences between system timezone and stored datetime in DB
Expected behavior
I would like to see true datetime in my timezone and my configured Datetime format
Desktop (please complete the following information):
- OS: Windows
- python 3.12.3
- django version 5.1.8
Additional context
My suggestion is to change file
scheduler/admin/task_admin.py
function
def task_schedule(self, o: Task):
from django.utils import timezone, formats
...
if o.task_type == TaskType.ONCE.value:
local_time = timezone.localtime(o.scheduled_time) #<----
return f"Run once: {formats.date_format(local_time, "DATETIME_FORMAT")}" #<----
elif o.task_type == TaskType.CRON.value:
...