mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-06 11:23:48 -05:00
notify-542: move to 24 hour time for UTC
This commit is contained in:
@@ -66,7 +66,6 @@ from app.formatters import (
|
||||
format_notification_type,
|
||||
format_number_in_pounds_as_currency,
|
||||
format_thousands,
|
||||
format_time,
|
||||
format_yes_no,
|
||||
id_safe,
|
||||
iteration_count,
|
||||
@@ -543,7 +542,6 @@ def add_template_filters(application):
|
||||
format_datetime_24h,
|
||||
format_datetime_normal,
|
||||
format_datetime_short,
|
||||
format_time,
|
||||
valid_phone_number,
|
||||
linkable_name,
|
||||
format_date,
|
||||
|
||||
@@ -36,7 +36,7 @@ def convert_to_boolean(value):
|
||||
def format_datetime(date):
|
||||
return '{} at {}'.format(
|
||||
format_date(date),
|
||||
format_time(date)
|
||||
format_time_24h(date)
|
||||
)
|
||||
|
||||
|
||||
@@ -50,21 +50,21 @@ def format_datetime_24h(date):
|
||||
def format_datetime_normal(date):
|
||||
return '{} at {}'.format(
|
||||
format_date_normal(date),
|
||||
format_time(date)
|
||||
format_time_24h(date)
|
||||
)
|
||||
|
||||
|
||||
def format_datetime_short(date):
|
||||
return '{} at {}'.format(
|
||||
format_date_short(date),
|
||||
format_time(date)
|
||||
format_time_24h(date)
|
||||
)
|
||||
|
||||
|
||||
def format_datetime_relative(date):
|
||||
return '{} at {}'.format(
|
||||
get_human_day(date),
|
||||
format_time(date)
|
||||
format_time_24h(date)
|
||||
)
|
||||
|
||||
|
||||
@@ -110,17 +110,6 @@ def get_human_day(time, date_prefix=''):
|
||||
).strip()
|
||||
|
||||
|
||||
def format_time(date):
|
||||
date = parse_naive_dt(date)
|
||||
return {
|
||||
'12:00AM': 'Midnight',
|
||||
'12:00PM': 'Noon'
|
||||
}.get(
|
||||
date.strftime('%-I:%M%p'),
|
||||
date.strftime('%-I:%M%p')
|
||||
).lower()
|
||||
|
||||
|
||||
def format_date(date):
|
||||
date = parse_naive_dt(date)
|
||||
return date.strftime('%A %d %B %Y')
|
||||
@@ -143,7 +132,7 @@ def format_date_human(date):
|
||||
def format_datetime_human(date, date_prefix=''):
|
||||
return '{} at {}'.format(
|
||||
get_human_day(date, date_prefix='on'),
|
||||
format_time(date),
|
||||
format_time_24h(date),
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -56,40 +56,39 @@ def test_format_number_in_pounds_as_currency(input_number, formatted_number):
|
||||
|
||||
|
||||
@pytest.mark.parametrize('time, human_readable_datetime', [
|
||||
# incoming in UTC, outgoing in local timezone
|
||||
# this test assumes timezone is America/New_York
|
||||
('2018-03-14 09:00', '14 March at 9:00am'),
|
||||
('2018-03-14 19:00', '14 March at 7:00pm'),
|
||||
# incoming in UTC, outgoing in "human formatted" UTC
|
||||
('2018-03-14 09:00', '14 March at 09:00'),
|
||||
('2018-03-14 19:00', '14 March at 19:00'),
|
||||
|
||||
('2018-03-15 09:00', '15 March at 9:00am'),
|
||||
('2018-03-15 19:00', '15 March at 7:00pm'),
|
||||
('2018-03-15 09:00', '15 March at 09:00'),
|
||||
('2018-03-15 19:00', '15 March at 19:00'),
|
||||
|
||||
('2018-03-19 09:00', '19 March at 9:00am'),
|
||||
('2018-03-19 19:00', '19 March at 7:00pm'),
|
||||
('2018-03-19 23:59', '19 March at 11:59pm'),
|
||||
('2018-03-19 09:00', '19 March at 09:00'),
|
||||
('2018-03-19 19:00', '19 March at 19:00'),
|
||||
('2018-03-19 23:59', '19 March at 23:59'),
|
||||
|
||||
('2018-03-20 00:00', '19 March at midnight'), # we specifically refer to 00:00 as belonging to the day before.
|
||||
('2018-03-20 04:01', 'yesterday at 4:01am'),
|
||||
('2018-03-20 09:00', 'yesterday at 9:00am'),
|
||||
('2018-03-20 19:00', 'yesterday at 7:00pm'),
|
||||
('2018-03-20 23:59', 'yesterday at 11:59pm'),
|
||||
('2018-03-20 00:00', '19 March at 00:00'), # we specifically refer to 00:00 as belonging to the day before.
|
||||
('2018-03-20 04:01', 'yesterday at 04:01'),
|
||||
('2018-03-20 09:00', 'yesterday at 09:00'),
|
||||
('2018-03-20 19:00', 'yesterday at 19:00'),
|
||||
('2018-03-20 23:59', 'yesterday at 23:59'),
|
||||
|
||||
('2018-03-21 00:00', 'yesterday at midnight'), # we specifically refer to 00:00 as belonging to the day before.
|
||||
('2018-03-21 04:01', 'today at 4:01am'),
|
||||
('2018-03-21 09:00', 'today at 9:00am'),
|
||||
('2018-03-21 12:00', 'today at noon'),
|
||||
('2018-03-21 19:00', 'today at 7:00pm'),
|
||||
('2018-03-21 23:59', 'today at 11:59pm'),
|
||||
('2018-03-21 00:00', 'yesterday at 00:00'), # we specifically refer to 00:00 as belonging to the day before.
|
||||
('2018-03-21 04:01', 'today at 04:01'),
|
||||
('2018-03-21 09:00', 'today at 09:00'),
|
||||
('2018-03-21 12:00', 'today at 12:00'),
|
||||
('2018-03-21 19:00', 'today at 19:00'),
|
||||
('2018-03-21 23:59', 'today at 23:59'),
|
||||
|
||||
('2018-03-22 00:00', 'today at midnight'), # we specifically refer to 00:00 as belonging to the day before.
|
||||
('2018-03-22 04:01', 'tomorrow at 4:01am'),
|
||||
('2018-03-22 09:00', 'tomorrow at 9:00am'),
|
||||
('2018-03-22 19:00', 'tomorrow at 7:00pm'),
|
||||
('2018-03-22 23:59', 'tomorrow at 11:59pm'),
|
||||
('2018-03-22 00:00', 'today at 00:00'),
|
||||
('2018-03-22 04:01', 'tomorrow at 04:01'),
|
||||
('2018-03-22 09:00', 'tomorrow at 09:00'),
|
||||
('2018-03-22 19:00', 'tomorrow at 19:00'),
|
||||
('2018-03-22 23:59', 'tomorrow at 23:59'),
|
||||
|
||||
('2018-03-23 04:01', '23 March at 4:01am'),
|
||||
('2018-03-23 09:00', '23 March at 9:00am'),
|
||||
('2018-03-23 19:00', '23 March at 7:00pm'),
|
||||
('2018-03-23 04:01', '23 March at 04:01'),
|
||||
('2018-03-23 09:00', '23 March at 09:00'),
|
||||
('2018-03-23 19:00', '23 March at 19:00'),
|
||||
|
||||
])
|
||||
def test_format_datetime_relative(time, human_readable_datetime):
|
||||
|
||||
@@ -153,7 +153,7 @@ def test_can_show_notifications(
|
||||
assert normalize_spaces(
|
||||
first_row.select_one('.table-field-right-aligned .align-with-message-body').text
|
||||
) == (
|
||||
'Delivered 1 January at 6:01am'
|
||||
'Delivered 1 January at 06:01'
|
||||
)
|
||||
|
||||
assert page_title in page.h1.text.strip()
|
||||
@@ -626,16 +626,16 @@ def test_redacts_templates_that_should_be_redacted(
|
||||
@freeze_time("2017-09-27 12:30:00.000000")
|
||||
@pytest.mark.parametrize(
|
||||
"message_type, status, expected_hint_status, single_line", [
|
||||
('email', 'created', 'Sending since 27 September at 12:30pm', True),
|
||||
('email', 'sending', 'Sending since 27 September at 12:30pm', True),
|
||||
('email', 'temporary-failure', 'Inbox not accepting messages right now 27 September at 12:31pm', False),
|
||||
('email', 'permanent-failure', 'Email address does not exist 27 September at 12:31pm', False),
|
||||
('email', 'delivered', 'Delivered 27 September at 12:31pm', True),
|
||||
('sms', 'created', 'Sending since 27 September at 12:30pm', True),
|
||||
('sms', 'sending', 'Sending since 27 September at 12:30pm', True),
|
||||
('sms', 'temporary-failure', 'Phone not accepting messages right now 27 September at 12:31pm', False),
|
||||
('sms', 'permanent-failure', 'Not delivered 27 September at 12:31pm', False),
|
||||
('sms', 'delivered', 'Delivered 27 September at 12:31pm', True),
|
||||
('email', 'created', 'Sending since 27 September at 12:30', True),
|
||||
('email', 'sending', 'Sending since 27 September at 12:30', True),
|
||||
('email', 'temporary-failure', 'Inbox not accepting messages right now 27 September at 12:31', False),
|
||||
('email', 'permanent-failure', 'Email address does not exist 27 September at 12:31', False),
|
||||
('email', 'delivered', 'Delivered 27 September at 12:31', True),
|
||||
('sms', 'created', 'Sending since 27 September at 12:30', True),
|
||||
('sms', 'sending', 'Sending since 27 September at 12:30', True),
|
||||
('sms', 'temporary-failure', 'Phone not accepting messages right now 27 September at 12:31', False),
|
||||
('sms', 'permanent-failure', 'Not delivered 27 September at 12:31', False),
|
||||
('sms', 'delivered', 'Delivered 27 September at 12:31', True),
|
||||
]
|
||||
)
|
||||
def test_sending_status_hint_displays_correctly_on_notifications_page(
|
||||
|
||||
Reference in New Issue
Block a user