diff --git a/app/__init__.py b/app/__init__.py
index 6d3994949..5292c767b 100644
--- a/app/__init__.py
+++ b/app/__init__.py
@@ -52,7 +52,7 @@ from app.formatters import (
format_datetime_human,
format_datetime_normal,
format_datetime_relative,
- format_datetime_short,
+ format_datetime_table,
format_day_of_week,
format_delta,
format_delta_days,
@@ -551,7 +551,7 @@ def add_template_filters(application):
format_datetime,
format_datetime_24h,
format_datetime_normal,
- format_datetime_short,
+ format_datetime_table,
valid_phone_number,
linkable_name,
format_date,
diff --git a/app/formatters.py b/app/formatters.py
index 24da3c5ef..c63b14776 100644
--- a/app/formatters.py
+++ b/app/formatters.py
@@ -87,16 +87,15 @@ def format_time(date):
def format_datetime_normal(date):
+ # example: February 20, 2024 at 07:00 PM US/Eastern, used for datetimes that's not within tables
return "{} at {} {}".format(
- format_date_normal(date), format_time_24h(date), get_user_preferred_timezone()
+ format_date_normal(date), format_time_12h(date), get_user_preferred_timezone()
)
-def format_datetime_short(date):
- # example: 03-18-2024 at 04:53 PM
- return "{} at {}".format(
- format_date_numeric(date), format_time_12h(date)
- )
+def format_datetime_table(date):
+ # example: 03-18-2024 at 04:53 PM, intended for datetimes in tables
+ return "{} at {}".format(format_date_numeric(date), format_time_12h(date))
def format_time_12h(date):
@@ -174,7 +173,7 @@ def format_date(date):
def format_date_normal(date):
date = parse_naive_dt(date)
- return date.strftime("%d %B %Y").lstrip("0")
+ return date.strftime("%B %d, %Y").lstrip("0")
def format_date_short(date):
diff --git a/app/main/views/jobs.py b/app/main/views/jobs.py
index 774f2a916..a728229d3 100644
--- a/app/main/views/jobs.py
+++ b/app/main/views/jobs.py
@@ -18,7 +18,7 @@ from notifications_utils.template import EmailPreviewTemplate, SMSBodyPreviewTem
from app import (
current_service,
- format_datetime_short,
+ format_datetime_table,
notification_api_client,
service_api_client,
)
@@ -93,7 +93,7 @@ def view_job_csv(service_id, job_id):
mimetype="text/csv",
headers={
"Content-Disposition": 'inline; filename="{} - {}.csv"'.format(
- job.template["name"], format_datetime_short(job.created_at)
+ job.template["name"], format_datetime_table(job.created_at)
)
},
)
diff --git a/app/templates/components/table.html b/app/templates/components/table.html
index 50eb73d9a..dab53fc1f 100644
--- a/app/templates/components/table.html
+++ b/app/templates/components/table.html
@@ -171,8 +171,8 @@
{% endif %}
{{ notification.status|format_notification_status_as_time(
- notification.created_at|format_datetime_short,
- (notification.sent_at or notification.created_at)|format_datetime_short
+ notification.created_at|format_datetime_table,
+ (notification.sent_at or notification.created_at)|format_datetime_table
) }}
{% if displayed_on_single_line %}{% endif %}
diff --git a/app/templates/partials/jobs/status.html b/app/templates/partials/jobs/status.html
index 703050e8d..7c73be426 100644
--- a/app/templates/partials/jobs/status.html
+++ b/app/templates/partials/jobs/status.html
@@ -2,12 +2,12 @@
{% if job.scheduled_for %}
{% if job.processing_started %}
- Sent by {{ job.created_by.name }} on {{ job.processing_started|format_datetime_short }}
+ Sent by {{ job.created_by.name }} on {{ job.processing_started|format_datetime_normal }}
{% else %}
- Uploaded by {{ job.created_by.name }} on {{ job.created_at|format_datetime_short }}
+ Uploaded by {{ job.created_by.name }} on {{ job.created_at|format_datetime_normal }}
{% endif %}
{% else %}
- Sent by {{ job.created_by.name }} on {{ job.created_at|format_datetime_short }}
+ Sent by {{ job.created_by.name }} on {{ job.created_at|format_datetime_normal }}
{% endif %}
{% if job.status == 'sending limits exceeded'%}
diff --git a/app/templates/views/api/keys.html b/app/templates/views/api/keys.html
index 4a9bf95e5..d32baa3e0 100644
--- a/app/templates/views/api/keys.html
+++ b/app/templates/views/api/keys.html
@@ -44,7 +44,7 @@
{% endcall %}
{% if item.expiry_date %}
{% call field(align='right') %}
- Revoked {{ item.expiry_date|format_datetime_short }}
+ Revoked {{ item.expiry_date|format_datetime_table }}
{% endcall %}
{% else %}
{% call field(align='right', status='error') %}
diff --git a/app/templates/views/dashboard/dashboard.html b/app/templates/views/dashboard/dashboard.html
index d61ab3f9c..c01c3c50f 100644
--- a/app/templates/views/dashboard/dashboard.html
+++ b/app/templates/views/dashboard/dashboard.html
@@ -68,7 +68,7 @@
{{ notification.template.name }}
- {{ job.created_at | format_datetime_short }}
+ {{ job.created_at | format_datetime_table }}
|
{{ notification.created_by.name }}
diff --git a/app/templates/views/platform-admin/complaints.html b/app/templates/views/platform-admin/complaints.html
index 10cf18fef..378d3b876 100644
--- a/app/templates/views/platform-admin/complaints.html
+++ b/app/templates/views/platform-admin/complaints.html
@@ -29,7 +29,7 @@
{{ text_field(item.complaint_type) }}
- {{ text_field(item.complaint_date|format_datetime_short if item.complaint_date else None) }}
+ {{ text_field(item.complaint_date|format_datetime_table if item.complaint_date else None) }}
{% endcall %}
diff --git a/tests/app/main/views/test_api_integration.py b/tests/app/main/views/test_api_integration.py
index c1ca57f22..51592b99e 100644
--- a/tests/app/main/views/test_api_integration.py
+++ b/tests/app/main/views/test_api_integration.py
@@ -6,7 +6,7 @@ from unittest.mock import call
import pytest
from flask import url_for
-from app.formatters import format_datetime_short
+from app.formatters import format_datetime_table
from tests import sample_uuid, validate_route_permission
from tests.conftest import SERVICE_ONE_ID, normalize_spaces
@@ -123,7 +123,7 @@ def test_should_show_api_keys_page(
assert rows[0] == "API keys Action"
assert (
rows[1]
- == f"another key name Revoked {format_datetime_short(date.fromtimestamp(0).isoformat())}"
+ == f"another key name Revoked {format_datetime_table(date.fromtimestamp(0).isoformat())}"
)
assert rows[2] == "some key name Revoke some key name"
diff --git a/tests/app/main/views/test_dashboard.py b/tests/app/main/views/test_dashboard.py
index 37674e797..83b861ed4 100644
--- a/tests/app/main/views/test_dashboard.py
+++ b/tests/app/main/views/test_dashboard.py
@@ -511,18 +511,18 @@ def test_download_inbox(
)
assert response.headers["Content-Type"] == ("text/csv; " "charset=utf-8")
assert response.headers["Content-Disposition"] == (
- "inline; " 'filename="Received text messages 2016-07-01.csv"'
+ "inline; " 'filename="Received text messages 07-01-2016.csv"'
)
assert response.get_data(as_text=True) == (
"Phone number,Message,Received\r\n"
- "(202) 867-5300,message-1,2016-07-01 11:00 US/Eastern\r\n"
- "(202) 867-5300,message-2,2016-07-01 10:59 US/Eastern\r\n"
- "(202) 867-5300,message-3,2016-07-01 10:59 US/Eastern\r\n"
- "(202) 867-5302,message-4,2016-07-01 08:59 US/Eastern\r\n"
- "+33 1 12 34 56 78,message-5,2016-07-01 06:59 US/Eastern\r\n"
- "(202) 555-0104,message-6,2016-07-01 04:59 US/Eastern\r\n"
- "(202) 555-0104,message-7,2016-07-01 02:59 US/Eastern\r\n"
- "+682 12345,message-8,2016-07-01 02:59 US/Eastern\r\n"
+ "(202) 867-5300,message-1,07-01-2016 11:00 US/Eastern\r\n"
+ "(202) 867-5300,message-2,07-01-2016 10:59 US/Eastern\r\n"
+ "(202) 867-5300,message-3,07-01-2016 10:59 US/Eastern\r\n"
+ "(202) 867-5302,message-4,07-01-2016 08:59 US/Eastern\r\n"
+ "+33 1 12 34 56 78,message-5,07-01-2016 06:59 US/Eastern\r\n"
+ "(202) 555-0104,message-6,07-01-2016 04:59 US/Eastern\r\n"
+ "(202) 555-0104,message-7,07-01-2016 02:59 US/Eastern\r\n"
+ "+682 12345,message-8,07-01-2016 02:59 US/Eastern\r\n"
)
diff --git a/tests/app/main/views/test_jobs.py b/tests/app/main/views/test_jobs.py
index 3076fe88f..6c8fd6193 100644
--- a/tests/app/main/views/test_jobs.py
+++ b/tests/app/main/views/test_jobs.py
@@ -424,7 +424,10 @@ def test_should_show_updates_for_one_job_as_json(
assert "2021234567" in content["notifications"]
assert "Status" in content["notifications"]
assert "Delivered" in content["notifications"]
- assert "Sent by Test User on 01-01-2016 at 12:00 AM" in content["status"]
+ assert (
+ "Sent by Test User on January 01, 2016 at 12:00 AM US/Eastern"
+ in content["status"]
+ )
assert "12:00" in content["notifications"]
@@ -466,7 +469,9 @@ def test_should_show_updates_for_scheduled_job_as_json(
assert "2021234567" in content["notifications"]
assert "Status" in content["notifications"]
assert "Delivered" in content["notifications"]
- assert "Sent by Test User on 06-01-2016 at 04:00 PM" in content["status"]
+ assert (
+ "Sent by Test User on June 01, 2016 at 04:00 PM US/Eastern" in content["status"]
+ )
assert "12:00" in content["notifications"]
diff --git a/tests/app/main/views/test_performance.py b/tests/app/main/views/test_performance.py
index ef2ed06be..5ceb5288b 100644
--- a/tests/app/main/views/test_performance.py
+++ b/tests/app/main/views/test_performance.py
@@ -116,26 +116,26 @@ def test_should_render_performance_page(
""
"Messages sent since May 2023 "
"Date Emails Text messages "
- "27 February 2021 1 2 "
- "26 February 2021 1 2 "
- "25 February 2021 1 2 "
- "24 February 2021 1 2 "
- "23 February 2021 1 2 "
- "22 February 2021 1 2 "
- "21 February 2021 1,234,567 123,456 "
+ "February 27, 2021 1 2 "
+ "February 26, 2021 1 2 "
+ "February 25, 2021 1 2 "
+ "February 24, 2021 1 2 "
+ "February 23, 2021 1 2 "
+ "February 22, 2021 1 2 "
+ "February 21, 2021 1,234,567 123,456 "
"Only showing the last 7 days "
""
"Messages sent within 10 seconds "
"98.31% on average "
"Messages sent within 10 seconds "
"Date Percentage "
- "27 February 2021 98.60% "
- "26 February 2021 100.00% "
- "25 February 2021 99.99% "
- "24 February 2021 100.00% "
- "23 February 2021 95.00% "
- "22 February 2021 95.30% "
- "21 February 2021 99.25% "
+ "February 27, 2021 98.60% "
+ "February 26, 2021 100.00% "
+ "February 25, 2021 99.99% "
+ "February 24, 2021 100.00% "
+ "February 23, 2021 95.00% "
+ "February 22, 2021 95.30% "
+ "February 21, 2021 99.25% "
"Only showing the last 7 days "
""
"Organizations using Notify "
|