mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-19 05:59:44 -04:00
Always use 12h times
The GOV.UK content style guide says: > - 5:30pm (not 1730hrs) > - midnight (not 00:00) > - midday (not 12 noon, noon or 12pm) This commit changes all times to be 12h not 24h, and adds a special case for when a time is exactly 12:00am or 12:00pm.
This commit is contained in:
@@ -105,6 +105,7 @@ def create_app():
|
||||
|
||||
application.add_template_filter(nl2br)
|
||||
application.add_template_filter(format_datetime)
|
||||
application.add_template_filter(format_datetime_24h)
|
||||
application.add_template_filter(format_datetime_normal)
|
||||
application.add_template_filter(format_datetime_short)
|
||||
application.add_template_filter(format_time)
|
||||
@@ -200,19 +201,41 @@ def gmt_timezones(date):
|
||||
|
||||
|
||||
def format_datetime(date):
|
||||
return gmt_timezones(date).strftime('%A %d %B %Y at %H:%M')
|
||||
return '{} at {}'.format(
|
||||
format_date(date),
|
||||
format_time(date)
|
||||
)
|
||||
|
||||
|
||||
def format_datetime_24h(date):
|
||||
return '{} at {}'.format(
|
||||
format_date(date),
|
||||
gmt_timezones(date).strftime('%H:%M')
|
||||
)
|
||||
|
||||
|
||||
def format_datetime_normal(date):
|
||||
return gmt_timezones(date).strftime('%d %B %Y at %H:%M').lstrip('0')
|
||||
return '{} at {}'.format(
|
||||
format_date_normal(date),
|
||||
format_time(date)
|
||||
)
|
||||
|
||||
|
||||
def format_datetime_short(date):
|
||||
return gmt_timezones(date).strftime('%d %B at %H:%M').lstrip('0')
|
||||
return '{} at {}'.format(
|
||||
format_date_short(date),
|
||||
format_time(date)
|
||||
)
|
||||
|
||||
|
||||
def format_time(date):
|
||||
return gmt_timezones(date).strftime('%H:%M')
|
||||
return {
|
||||
'12:00AM': 'Midnight',
|
||||
'12:00PM': 'Midday'
|
||||
}.get(
|
||||
gmt_timezones(date).strftime('%-I:%M%p'),
|
||||
gmt_timezones(date).strftime('%-I:%M%p')
|
||||
).lower()
|
||||
|
||||
|
||||
def format_date(date):
|
||||
|
||||
@@ -89,7 +89,7 @@ def get_errors_for_csv(recipients, template_type):
|
||||
|
||||
|
||||
def generate_notifications_csv(json_list):
|
||||
from app import format_datetime, format_notification_status
|
||||
from app import format_datetime_24h, format_notification_status
|
||||
content = StringIO()
|
||||
retval = None
|
||||
with content as csvfile:
|
||||
@@ -103,7 +103,7 @@ def generate_notifications_csv(json_list):
|
||||
x['template']['template_type'],
|
||||
x['job']['original_file_name'] if x['job'] else '',
|
||||
format_notification_status(x['status'], x['template']['template_type']),
|
||||
format_datetime(x['created_at'])])
|
||||
format_datetime_24h(x['created_at'])])
|
||||
retval = content.getvalue()
|
||||
return retval
|
||||
|
||||
|
||||
Reference in New Issue
Block a user