mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-13 00:32:16 -05:00
Add date helper methods to be used as date range filters for notification counts
This commit is contained in:
12
app/utils.py
12
app/utils.py
@@ -1,3 +1,5 @@
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from flask import url_for
|
||||
from app.models import SMS_TYPE, EMAIL_TYPE
|
||||
from notifications_utils.template import SMSMessageTemplate, PlainTextEmailTemplate
|
||||
@@ -26,3 +28,13 @@ def get_template_instance(template, values):
|
||||
return {
|
||||
SMS_TYPE: SMSMessageTemplate, EMAIL_TYPE: PlainTextEmailTemplate
|
||||
}[template['template_type']](template, values)
|
||||
|
||||
|
||||
def get_midnight_for_date(date):
|
||||
midnight = datetime.combine(date, datetime.min.time())
|
||||
return midnight
|
||||
|
||||
|
||||
def get_midnight_for_day_before(date):
|
||||
day_before = date - timedelta(1)
|
||||
return get_midnight_for_date(day_before)
|
||||
|
||||
Reference in New Issue
Block a user