Skip to content

Commit

Permalink
naive date transformed into UTC before saving on django
Browse files Browse the repository at this point in the history
  • Loading branch information
guglielmo committed Jun 18, 2020
1 parent 83ab865 commit 0eff4f3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions taskmanager/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import datetime
import os
import pytz
from pathlib import Path
from typing import TYPE_CHECKING

Expand Down Expand Up @@ -121,7 +122,7 @@ def exec_command_task(curr_task: "Task"):
# Re-schedule the Task if needed
if curr_task.repetition_period:
curr_task.status = Task.STATUS_SPOOLED
now = datetime.datetime.now()
now = datetime.datetime.now(pytz.timezone('UTC'))
if not curr_task.repetition_rate:
curr_task.repetition_rate = 1
if curr_task.repetition_period == Task.REPETITION_PERIOD_MINUTE:
Expand Down Expand Up @@ -176,7 +177,7 @@ def exec_command_task(curr_task: "Task"):
schedule = str(int(next_ride.timestamp())).encode()
task_id = exec_command_task.spool(curr_task, at=schedule)
curr_task.spooler_id = task_id.decode("utf-8")
curr_task.cached_next_ride = next_ride
curr_task.cached_next_ride = next_ride.replace(tzinfo=None)
else:
curr_task.status = Task.STATUS_IDLE
if curr_task.spooler_id:
Expand Down

0 comments on commit 0eff4f3

Please sign in to comment.