diff --git a/app/config.py b/app/config.py index b204c229a..0b7fd83aa 100644 --- a/app/config.py +++ b/app/config.py @@ -15,8 +15,7 @@ class Config(object): HEADER_COLOUR = '#81878b' # mix(govuk-colour("dark-grey"), govuk-colour("mid-grey")) LOGO_CDN_DOMAIN = 'static-logos.notifications.service.gov.uk' # TODO use our own CDN ASSETS_DEBUG = False - TIMEZONE = getenv('TIMEZONE', 'America/New_York') - PY_TIMEZONE = pytz.timezone(TIMEZONE) + PY_TIMEZONE = pytz.utc # Credentials ADMIN_CLIENT_SECRET = getenv('ADMIN_CLIENT_SECRET') diff --git a/app/formatters.py b/app/formatters.py index 3e6b44320..ce84f3336 100644 --- a/app/formatters.py +++ b/app/formatters.py @@ -18,7 +18,6 @@ from notifications_utils.recipients import ( validate_phone_number, ) from notifications_utils.take import Take -from notifications_utils.timezones import convert_utc_to_local_timezone from app.utils.time import parse_naive_dt @@ -77,19 +76,19 @@ def format_datetime_numeric(date): def format_date_numeric(date): date = parse_naive_dt(date) - return convert_utc_to_local_timezone(date).strftime('%Y-%m-%d') + return date.strftime('%Y-%m-%d') def format_time_24h(date): date = parse_naive_dt(date) - return convert_utc_to_local_timezone(date).strftime('%H:%M') + return date.strftime('%H:%M') def get_human_day(time, date_prefix=''): # Add 1 minute to transform 00:00 into ‘midnight today’ instead of ‘midnight tomorrow’ time = parse_naive_dt(time) - date = (convert_utc_to_local_timezone(time) - timedelta(minutes=1)).date() + date = (time - timedelta(minutes=1)).date() now = datetime.now(current_app.config['PY_TIMEZONE']) if date == (now + timedelta(days=1)).date(): @@ -116,24 +115,24 @@ def format_time(date): '12:00AM': 'Midnight', '12:00PM': 'Noon' }.get( - convert_utc_to_local_timezone(date).strftime('%-I:%M%p'), - convert_utc_to_local_timezone(date).strftime('%-I:%M%p') + date.strftime('%-I:%M%p'), + date.strftime('%-I:%M%p') ).lower() def format_date(date): date = parse_naive_dt(date) - return convert_utc_to_local_timezone(date).strftime('%A %d %B %Y') + return date.strftime('%A %d %B %Y') def format_date_normal(date): date = parse_naive_dt(date) - return convert_utc_to_local_timezone(date).strftime('%d %B %Y').lstrip('0') + return date.strftime('%d %B %Y').lstrip('0') def format_date_short(date): date = parse_naive_dt(date) - return _format_datetime_short(convert_utc_to_local_timezone(date)) + return _format_datetime_short(date) def format_date_human(date): @@ -149,7 +148,7 @@ def format_datetime_human(date, date_prefix=''): def format_day_of_week(date): date = parse_naive_dt(date) - return convert_utc_to_local_timezone(date).strftime('%A') + return date.strftime('%A') def _format_datetime_short(datetime): diff --git a/app/main/forms.py b/app/main/forms.py index 3b8f3718e..cd3349d62 100644 --- a/app/main/forms.py +++ b/app/main/forms.py @@ -73,7 +73,7 @@ from app.utils.user_permissions import all_ui_permissions, permission_options def get_time_value_and_label(future_time): return ( future_time.astimezone(pytz.utc).replace(tzinfo=None).isoformat(), - '{} at {} ET'.format( + '{} at {} UTC'.format( get_human_day(future_time.astimezone(current_app.config['PY_TIMEZONE'])), get_human_time(future_time.astimezone(current_app.config['PY_TIMEZONE'])) ) diff --git a/app/models/user.py b/app/models/user.py index b99e30a2e..bb1403e6c 100644 --- a/app/models/user.py +++ b/app/models/user.py @@ -3,7 +3,6 @@ from datetime import datetime from flask import abort, current_app, request, session from flask_login import AnonymousUserMixin, UserMixin, login_user, logout_user from notifications_python_client.errors import HTTPError -from notifications_utils.timezones import convert_utc_to_local_timezone from werkzeug.utils import cached_property from app.event_handlers import ( @@ -129,11 +128,7 @@ class User(JSONModel, UserMixin): return False datetime_string = parse_naive_dt(datetime_string) changed = parse_naive_dt(self.password_changed_at) - return convert_utc_to_local_timezone( - changed - ) > convert_utc_to_local_timezone( - datetime_string - ) + return changed > datetime_string def set_permissions(self, service_id, permissions, folder_permissions, set_by_id): user_api_client.set_user_permissions( diff --git a/app/templates/views/message-status.html b/app/templates/views/message-status.html index aef6c9feb..43f815d38 100644 --- a/app/templates/views/message-status.html +++ b/app/templates/views/message-status.html @@ -12,6 +12,12 @@
Notify’s real-time dashboard lets you check the status of any message.
For security, this information is only available for seven days after a message has been sent. You can download a report, including a list of sent messages, for your own records.
This page describes the statuses you’ll see when you’re signed in to Notify.
+ +Notify currently uses UTC (Coordinated Universal Time) for managing and displaying all dates and times in the system. This means that when you're scheduling messages to send later, or are looking at the time a message was sent, it will be in the UTC timezone.
+ +You can refer to this chart for help with converting UTC times to your local timezone.