mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-05 06:01:46 -04:00
Make it say later today
Categories before: > Now, today, tomorrow, Friday… Categories after: > Now, later today, tomorrow Friday… This reduces the ambiguity of ‘now’ vs ‘today’, and keeping the word ‘later’ suggests what this features is about. This implementation here is a bit hacky, but it works…
This commit is contained in:
@@ -44,11 +44,11 @@ def get_human_time(time):
|
||||
)
|
||||
|
||||
|
||||
def get_human_day(time):
|
||||
def get_human_day(time, prefix_today_with='T'):
|
||||
# Add 1 hour to get ‘midnight today’ instead of ‘midnight tomorrow’
|
||||
time = (time - timedelta(hours=1)).strftime('%A')
|
||||
if time == datetime.utcnow().strftime('%A'):
|
||||
return 'Today'
|
||||
return '{}oday'.format(prefix_today_with)
|
||||
if time == (datetime.utcnow() + timedelta(days=1)).strftime('%A'):
|
||||
return 'Tomorrow'
|
||||
return time
|
||||
@@ -71,7 +71,10 @@ def get_next_days_until(until):
|
||||
now = datetime.utcnow()
|
||||
days = int((until - now).total_seconds() / (60 * 60 * 24))
|
||||
return [
|
||||
get_human_day((now + timedelta(days=i)).replace(tzinfo=pytz.utc))
|
||||
get_human_day(
|
||||
(now + timedelta(days=i)).replace(tzinfo=pytz.utc),
|
||||
prefix_today_with='Later t'
|
||||
)
|
||||
for i in range(0, days + 1)
|
||||
]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user