From 430ff93e45846ae74cb6d7826eb91fbd3cc770ca Mon Sep 17 00:00:00 2001 From: Klaus-Uwe Mitterer Date: Thu, 31 Dec 2020 22:15:52 +0100 Subject: [PATCH] Make message handler use local time instead of UTC --- msgio/handler.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/msgio/handler.py b/msgio/handler.py index 1c2a7b4..1a192a0 100644 --- a/msgio/handler.py +++ b/msgio/handler.py @@ -1,5 +1,5 @@ from django.dispatch import receiver -from django.utils.timezone import now +from django.utils.timezone import localtime, now from cronhandler.signals import cron @@ -10,7 +10,7 @@ def send_notifications(sender, **kwargs): returns = [] for notification in Notification.objects.all(): for datetime in notification.notificationdatetimeschedule_set.all(): - if not datetime.sent and datetime.datetime <= now(): + if not datetime.sent and datetime.datetime <= localtime(now()): try: returns.append(notification.send()) datetime.sent = True @@ -18,10 +18,10 @@ def send_notifications(sender, **kwargs): except: pass # TODO: Implement some sort of error logging / admin notification for daily in notification.notificationdailyschedule_set.all(): - if ((not daily.last_sent) or daily.last_sent < now().date()) and daily.time <= now().time(): + if ((not daily.last_sent) or daily.last_sent < localtime(now()).date()) and daily.time <= localtime(now()).time(): try: returns.append(notification.send()) - daily.last_sent = now().date() + daily.last_sent = localtime(now()).date() daily.save() except: pass # TODO: See above