Merge pull request #1291 from alphagov/two-way

Add page to show two-way conversation
This commit is contained in:
Chris Hill-Scott
2017-06-14 16:42:46 +01:00
committed by GitHub
12 changed files with 359 additions and 13 deletions

View File

@@ -257,13 +257,20 @@ def format_datetime_relative(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'):
time_as_day = (gmt_timezones(time) - timedelta(hours=1)).strftime('%A')
six_days_ago = gmt_timezones((datetime.utcnow() + timedelta(days=-6)).isoformat())
if gmt_timezones(time) < six_days_ago:
return format_date_short(time)
if time_as_day == (datetime.utcnow() + timedelta(days=1)).strftime('%A'):
return 'tomorrow'
return time
if time_as_day == datetime.utcnow().strftime('%A'):
return 'today'
if time_as_day == (datetime.utcnow() + timedelta(days=-1)).strftime('%A'):
return 'yesterday'
return format_date_short(time)
def format_time(date):