mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-02 17:48:50 -04:00
Add years to old dates
Just to disambiguate things without introducing unnecessary noise.
This commit is contained in:
@@ -297,12 +297,16 @@ def get_human_day(time):
|
|||||||
|
|
||||||
# Add 1 minute to transform 00:00 into ‘midnight today’ instead of ‘midnight tomorrow’
|
# Add 1 minute to transform 00:00 into ‘midnight today’ instead of ‘midnight tomorrow’
|
||||||
date = (utc_string_to_aware_gmt_datetime(time) - timedelta(minutes=1)).date()
|
date = (utc_string_to_aware_gmt_datetime(time) - timedelta(minutes=1)).date()
|
||||||
if date == (datetime.utcnow() + timedelta(days=1)).date():
|
now = datetime.utcnow()
|
||||||
|
|
||||||
|
if date == (now + timedelta(days=1)).date():
|
||||||
return 'tomorrow'
|
return 'tomorrow'
|
||||||
if date == datetime.utcnow().date():
|
if date == now.date():
|
||||||
return 'today'
|
return 'today'
|
||||||
if date == (datetime.utcnow() - timedelta(days=1)).date():
|
if date == (now - timedelta(days=1)).date():
|
||||||
return 'yesterday'
|
return 'yesterday'
|
||||||
|
if date.strftime('%Y') != now.strftime('%Y'):
|
||||||
|
return '{} {}'.format(_format_datetime_short(date), date.strftime('%Y'))
|
||||||
return _format_datetime_short(date)
|
return _format_datetime_short(date)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import pytest
|
import pytest
|
||||||
|
from freezegun import freeze_time
|
||||||
|
|
||||||
from tests.conftest import SERVICE_ONE_ID, normalize_spaces
|
from tests.conftest import SERVICE_ONE_ID, normalize_spaces
|
||||||
|
|
||||||
@@ -20,14 +21,14 @@ from tests.conftest import SERVICE_ONE_ID, normalize_spaces
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'11 November',
|
'11 November 2011',
|
||||||
(
|
(
|
||||||
'Test User 11:11am '
|
'Test User 11:11am '
|
||||||
'Created an API key called ‘Bad key’'
|
'Created an API key called ‘Bad key’'
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'10 October',
|
'10 October 2010',
|
||||||
(
|
(
|
||||||
'Test User 11:10am '
|
'Test User 11:10am '
|
||||||
'Created an API key called ‘Good key’ '
|
'Created an API key called ‘Good key’ '
|
||||||
@@ -45,14 +46,14 @@ from tests.conftest import SERVICE_ONE_ID, normalize_spaces
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'11 November',
|
'11 November 2011',
|
||||||
(
|
(
|
||||||
'Test User 11:11am '
|
'Test User 11:11am '
|
||||||
'Created an API key called ‘Bad key’'
|
'Created an API key called ‘Bad key’'
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'10 October',
|
'10 October 2010',
|
||||||
(
|
(
|
||||||
'Test User 11:10am '
|
'Test User 11:10am '
|
||||||
'Created an API key called ‘Good key’'
|
'Created an API key called ‘Good key’'
|
||||||
@@ -68,7 +69,7 @@ from tests.conftest import SERVICE_ONE_ID, normalize_spaces
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'10 October',
|
'10 October 2010',
|
||||||
(
|
(
|
||||||
'Unknown 2:01am '
|
'Unknown 2:01am '
|
||||||
'Created this service and called it ‘Example service’'
|
'Created this service and called it ‘Example service’'
|
||||||
@@ -76,6 +77,7 @@ from tests.conftest import SERVICE_ONE_ID, normalize_spaces
|
|||||||
),
|
),
|
||||||
]),
|
]),
|
||||||
))
|
))
|
||||||
|
@freeze_time("2012-01-01 01:01:01")
|
||||||
def test_history(
|
def test_history(
|
||||||
client_request,
|
client_request,
|
||||||
mock_get_service_history,
|
mock_get_service_history,
|
||||||
|
|||||||
@@ -45,11 +45,11 @@ from tests.conftest import (
|
|||||||
),
|
),
|
||||||
(
|
(
|
||||||
'send_me_later.csv '
|
'send_me_later.csv '
|
||||||
'Sending 1 January at 11:09am 1'
|
'Sending 1 January 2016 at 11:09am 1'
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'even_later.csv '
|
'even_later.csv '
|
||||||
'Sending 1 January at 11:09pm 1'
|
'Sending 1 January 2016 at 11:09pm 1'
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'File Sending Delivered Failed'
|
'File Sending Delivered Failed'
|
||||||
|
|||||||
Reference in New Issue
Block a user