diff --git a/app/__init__.py b/app/__init__.py index 4d68a06541..f81f330ac9 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -496,8 +496,8 @@ def _getStatusByBounceSubtype(): def format_notification_status_as_time(status, created, updated): return dict.fromkeys( {"created", "pending", "sending"}, - " " + _("since") + ' {}'.format(created), - ).get(status, '{}'.format(updated)) + " " + _("since") + ' '.format(created), + ).get(status, ''.format(updated)) def format_notification_status_as_field_status(status, notification_type): diff --git a/app/assets/javascripts/main.js b/app/assets/javascripts/main.js index eea5436e66..5fd724c719 100644 --- a/app/assets/javascripts/main.js +++ b/app/assets/javascripts/main.js @@ -1,37 +1,44 @@ window.formatAllDates = function () { $(".local-datetime-short").each(function (index) { - let datetime = new Date($(this).text().trim()); + let datetimeRaw = $(this).text().trim(); + let datetime = new Date(datetimeRaw); let locale = window.APP_LANG == "fr" ? "fr-CA" : "en-US"; if (datetime instanceof Date && !isNaN(datetime)) { - $(this).text( - datetime.toLocaleString(locale, { - month: "short", - day: "numeric", - hour: "numeric", - minute: "2-digit", - }), - ); + $(this) + .attr("datetime", datetimeRaw) + .text( + datetime.toLocaleString(locale, { + month: "short", + day: "numeric", + hour: "numeric", + minute: "2-digit", + }), + ); } }); $(".local-datetime-short-year").each(function (index) { - let datetime = new Date($(this).text().trim()); + let datetimeRaw = $(this).text().trim(); + let datetime = new Date(datetimeRaw); let locale = window.APP_LANG == "fr" ? "fr-CA" : "en-US"; if (datetime instanceof Date && !isNaN(datetime)) { - $(this).text( - datetime.toLocaleString(locale, { - month: "short", - day: "numeric", - year: "numeric", - }), - ); + $(this) + .attr("datetime", datetimeRaw) + .text( + datetime.toLocaleString(locale, { + month: "short", + day: "numeric", + year: "numeric", + }), + ); } }); $(".local-datetime-full").each(function (index) { - let datetime = new Date($(this).text().trim()); + let datetimeRaw = $(this).text().trim(); + let datetime = new Date(datetimeRaw); let locale = window.APP_LANG == "fr" ? "fr-CA" : "en-US"; if ($(this).text().trim() === "None") { @@ -39,31 +46,34 @@ window.formatAllDates = function () { } if (datetime instanceof Date && !isNaN(datetime)) { - $(this).text( - datetime.toLocaleDateString(locale, { dateStyle: "long" }) + - ", " + - datetime.toLocaleTimeString(locale, { timeStyle: "short" }), - ); + $(this) + .attr("datetime", datetimeRaw) + .text( + datetime.toLocaleDateString(locale, { dateStyle: "long" }) + + ", " + + datetime.toLocaleTimeString(locale, { timeStyle: "short" }), + ); } }); $(".relative-time-past").each(function (index) { - let timeRaw = new Date($(this).text().trim()); + let datetimeRaw = $(this).text().trim(); + let datetime = new Date($(this).text().trim()); let locale = window.APP_LANG == "fr" ? "fr-CA" : "en-US"; - let time = moment(timeRaw); + let time = moment(datetime); if (time.isValid() && window.APP_LANG) { let isToday = moment().isSame(time, "day"); let dayStr = ""; - let timeStr = timeRaw.toLocaleTimeString(locale, { timeStyle: "short" }); + let timeStr = datetime.toLocaleTimeString(locale, { timeStyle: "short" }); if (isToday && window.APP_PHRASES) { dayStr = window.APP_PHRASES["today"]; } else { - dayStr = timeRaw.toLocaleDateString(locale, { dateStyle: "long" }); + dayStr = datetime.toLocaleDateString(locale, { dateStyle: "long" }); } - $(this).text(`${dayStr}, ${timeStr}`); + $(this).attr("datetime", datetimeRaw).text(`${dayStr}, ${timeStr}`); } }); }; diff --git a/app/templates/partials/jobs/notifications_header.html b/app/templates/partials/jobs/notifications_header.html index bb018402bf..41db71674c 100644 --- a/app/templates/partials/jobs/notifications_header.html +++ b/app/templates/partials/jobs/notifications_header.html @@ -24,7 +24,7 @@ {% else %} {{ _('Download this report') }}
- Provided as PDF on {{ created_at }} + Provided as PDF on
Validation failed – this isn’t a PDF file that Notification can read diff --git a/app/templates/views/notifications/notification.html b/app/templates/views/notifications/notification.html index 695c970beb..555de52462 100644 --- a/app/templates/views/notifications/notification.html +++ b/app/templates/views/notifications/notification.html @@ -44,14 +44,14 @@ {% elif created_by %} {{ _('by') }} {{ created_by.name }} {% endif %} - {{ _('on') }} {{ created_at }} + {{ _('on') }}
{% if template.template_type == 'letter' %} {% if notification_status in ('permanent-failure', 'cancelled') %}- Cancelled {{ updated_at }} + Cancelled
{% elif notification_status == 'validation-failed' %}diff --git a/app/templates/views/platform-admin/complaints.html b/app/templates/views/platform-admin/complaints.html index 97dd813a27..750399ee7d 100644 --- a/app/templates/views/platform-admin/complaints.html +++ b/app/templates/views/platform-admin/complaints.html @@ -29,7 +29,7 @@
- {{ _('This template was deleted') }} {{ template._template.updated_at }}. + {{ _('This template was deleted') }} .
{% elif not current_user.has_permissions('send_messages', 'manage_api_keys', 'manage_templates', 'manage_service') or not user_has_template_permission %}diff --git a/app/templates/views/templates/_template_history.html b/app/templates/views/templates/_template_history.html index 1bc33b516d..f6423687cf 100644 --- a/app/templates/views/templates/_template_history.html +++ b/app/templates/views/templates/_template_history.html @@ -7,10 +7,10 @@