Calculate status based off Alberta timezone

This commit is contained in:
Tanner Collin 2020-02-10 01:00:41 +00:00
parent 63fd53f42a
commit ad29bb39eb
2 changed files with 8 additions and 3 deletions

View File

@ -159,7 +159,7 @@ class TestCalcStatus(TestCase):
self.assertEqual(former, False) self.assertEqual(former, False)
def test_calc_member_status_today(self): def test_calc_member_status_today(self):
expire_date = datetime.date.today() expire_date = utils.today_alberta_tz()
status, former = utils.calc_member_status(expire_date) status, former = utils.calc_member_status(expire_date)

View File

@ -1,6 +1,6 @@
import datetime
import io import io
import requests import requests
from datetime import datetime, timedelta
from rest_framework.exceptions import ValidationError from rest_framework.exceptions import ValidationError
from dateutil import relativedelta from dateutil import relativedelta
from uuid import uuid4 from uuid import uuid4
@ -12,6 +12,7 @@ from reportlab.lib.pagesizes import letter
from django.db.models import Sum from django.db.models import Sum
from django.core.cache import cache from django.core.cache import cache
from django.utils.timezone import now, pytz
from . import models, serializers, utils_ldap from . import models, serializers, utils_ldap
try: try:
@ -23,6 +24,9 @@ except ImportError:
STATIC_FOLDER = 'data/static/' STATIC_FOLDER = 'data/static/'
def today_alberta_tz():
return datetime.now(pytz.timezone('America/Edmonton')).date()
def num_months_spanned(d1, d2): def num_months_spanned(d1, d2):
''' '''
Return number of month thresholds two dates span. Return number of month thresholds two dates span.
@ -44,7 +48,8 @@ def calc_member_status(expire_date, fake_date=None):
''' '''
Return: status, if we should pause them Return: status, if we should pause them
''' '''
today = fake_date or datetime.date.today() today = fake_date or today_alberta_tz()
difference = num_months_difference(expire_date, today) difference = num_months_difference(expire_date, today)
#if today + datetime.timedelta(days=29) < expire_date: #if today + datetime.timedelta(days=29) < expire_date: