mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-18 05:29:38 -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):
|
||||
|
||||
Reference in New Issue
Block a user