From e49d2d963a74a65b2e9519856f2611b3af8c0570 Mon Sep 17 00:00:00 2001 From: Yingtong Li Date: Sat, 4 Jan 2020 17:14:34 +1100 Subject: [PATCH] Ensures bulletin sends correctly if running across midnight --- sspromotions/management/commands/sendbulletin.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sspromotions/management/commands/sendbulletin.py b/sspromotions/management/commands/sendbulletin.py index 9330bfc..1d41781 100644 --- a/sspromotions/management/commands/sendbulletin.py +++ b/sspromotions/management/commands/sendbulletin.py @@ -33,6 +33,8 @@ import logging import time import urllib.parse +bulldt = timezone.localtime(timezone.now()) + def send_aws_email(client, email, subject, content_html, content_txt): def send_mail(**kwargs): for i in range(0, 10): @@ -91,9 +93,9 @@ class Command(BaseCommand): client = boto3.client('ses', aws_access_key_id=settings.AWS_KEY_ID, aws_secret_access_key=settings.AWS_SECRET, region_name=settings.AWS_REGION) - title = '{} News: {}'.format(settings.ORG_NAME, timezone.localtime(timezone.now()).strftime('%d %B %Y')) + title = '{} News: {}'.format(settings.ORG_NAME, bulldt.strftime('%d %B %Y')) - calbegin, calend, bulbegin, bulend = sspromotions.utils.bulletin_dates(timezone.localtime(timezone.now())) + calbegin, calend, bulbegin, bulend = sspromotions.utils.bulletin_dates(bulldt) events = list(sspromotions.utils.get_calendar_events(calbegin, calend)) for member in members: