diff --git a/cl/custom_filters/templatetags/extras.py b/cl/custom_filters/templatetags/extras.py index 39d535b2df..6532ca2881 100644 --- a/cl/custom_filters/templatetags/extras.py +++ b/cl/custom_filters/templatetags/extras.py @@ -1,7 +1,7 @@ import random import re import urllib.parse -from datetime import datetime +from datetime import datetime, timezone import waffle from django import template @@ -337,6 +337,21 @@ def format_date(date_str: str) -> str: return date_str +@register.filter +def datetime_in_utc(date_obj) -> str: + """Formats a datetime object in UTC with timezone displayed. + For example: 'Nov. 25, 2024, 01:28 p.m. UTC'""" + if date_obj is None: + return "" + try: + return date_filter( + date_obj.astimezone(timezone.utc), + "M. j, Y, h:i a T", + ) + except (ValueError, TypeError): + return date_obj + + @register.filter def build_docket_id_q_param(request_q: str, docket_id: str) -> str: """Build a query string that includes the docket ID and any existing query diff --git a/cl/users/templates/includes/webhook-event-detail.html b/cl/users/templates/includes/webhook-event-detail.html index 20f631fb53..9f70262daa 100644 --- a/cl/users/templates/includes/webhook-event-detail.html +++ b/cl/users/templates/includes/webhook-event-detail.html @@ -1,4 +1,5 @@ {% extends "profile/webhooks_base.html" %} +{% load extras %} {% load static %} {% load waffle_tags %} {% load humanize %} @@ -13,11 +14,11 @@
{% if webhook_event.webhook.enabled %} Enabled {% else %} Disabled {% endif %}
{{ webhook_event.webhook.get_event_type_display }}
{{ webhook_event.event_id }}
-{{ webhook_event.date_created }}
+{{ webhook_event.date_created|datetime_in_utc }}
{% if webhook_event.status_code %}{{ webhook_event.status_code }} {{ webhook_event.get_status_code_display }} {% else %}-{% endif %}
{{ webhook_event.get_event_status_display }}
{{ webhook_event.retry_counter }}
-{% if not webhook_event.debug %}{% if webhook_event.next_retry_date %}{{ webhook_event.next_retry_date }}{% else %}-{% endif %}{% else %}Test events will not be retried{% endif %}
+{% if not webhook_event.debug %}{% if webhook_event.next_retry_date %}{{ webhook_event.next_retry_date|datetime_in_utc }}{% else %}-{% endif %}{% else %}Test events will not be retried{% endif %}