mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-31 23:26:23 -05:00
pull timezone from utils for other pytz instances
This commit is contained in:
@@ -5,6 +5,7 @@ import pytz
|
||||
from notifications_utils.timezones import (
|
||||
convert_local_timezone_to_utc,
|
||||
convert_utc_to_local_timezone,
|
||||
local_timezone
|
||||
)
|
||||
|
||||
|
||||
@@ -50,7 +51,7 @@ def get_april_fools(year):
|
||||
:param year: the year to calculate the April 1, 00:00 BST for
|
||||
:return: the datetime of April 1 for the given year, for example 2016 = 2016-03-31 23:00:00
|
||||
"""
|
||||
return pytz.timezone(getenv("TIMEZONE", "America/New_York")).localize(
|
||||
return local_timezone.localize(
|
||||
datetime(year, 4, 1, 0, 0, 0)).astimezone(pytz.UTC).replace(tzinfo=None)
|
||||
|
||||
|
||||
|
||||
@@ -8,13 +8,12 @@ from notifications_utils.template import (
|
||||
LetterPrintTemplate,
|
||||
SMSMessageTemplate,
|
||||
)
|
||||
from notifications_utils.timezones import convert_local_timezone_to_utc
|
||||
from notifications_utils.timezones import convert_local_timezone_to_utc, local_timezone
|
||||
from sqlalchemy import func
|
||||
|
||||
DATETIME_FORMAT_NO_TIMEZONE = "%Y-%m-%d %H:%M:%S.%f"
|
||||
DATETIME_FORMAT = "%Y-%m-%dT%H:%M:%S.%fZ"
|
||||
DATE_FORMAT = "%Y-%m-%d"
|
||||
local_timezone = pytz.timezone(getenv("TIMEZONE", "America/New_York"))
|
||||
|
||||
|
||||
def pagination_links(pagination, endpoint, **kwargs):
|
||||
@@ -60,8 +59,8 @@ def get_local_midnight_in_utc(date):
|
||||
"""
|
||||
This function converts date from midnight in local time to UTC,
|
||||
removing the tzinfo from the datetime because the database stores the timestamps without timezone.
|
||||
:param date: the day to calculate the London midnight in UTC for
|
||||
:return: the datetime of London midnight in UTC, for example 2016-06-17 = 2016-06-16 23:00:00
|
||||
:param date: the day to calculate the local midnight in UTC for
|
||||
:return: the datetime of local midnight in UTC, for example 2016-06-17 = 2016-06-16 23:00:00
|
||||
"""
|
||||
return convert_local_timezone_to_utc(datetime.combine(date, datetime.min.time()))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user