diff --git a/app/__init__.py b/app/__init__.py index 17b17c563..375bc677a 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -117,6 +117,7 @@ def create_app(): application.add_template_filter(format_date) application.add_template_filter(format_date_normal) application.add_template_filter(format_date_short) + application.add_template_filter(format_datetime_relative) application.add_template_filter(format_delta) application.add_template_filter(format_notification_status) application.add_template_filter(format_notification_status_as_time) @@ -232,6 +233,23 @@ def format_datetime_short(date): ) +def format_datetime_relative(date): + return '{} at {}'.format( + get_human_day(date), + format_time(date) + ) + + +def get_human_day(time): + # Add 1 hour to get ‘midnight today’ instead of ‘midnight tomorrow’ + time = (gmt_timezones(time) - timedelta(hours=1)).strftime('%A') + if time == datetime.utcnow().strftime('%A'): + return 'today' + if time == (datetime.utcnow() + timedelta(days=1)).strftime('%A'): + return 'tomorrow' + return time + + def format_time(date): return { '12:00AM': 'Midnight', diff --git a/app/templates/partials/jobs/notifications.html b/app/templates/partials/jobs/notifications.html index 408073a39..9ef4ef6ad 100644 --- a/app/templates/partials/jobs/notifications.html +++ b/app/templates/partials/jobs/notifications.html @@ -5,7 +5,7 @@ {% if job.job_status == 'scheduled' %}
- Sending will start at {{ job.scheduled_for|format_time }} + Sending will start {{ job.scheduled_for|format_datetime_relative }}