diff options
author | Thomas Pointhuber <thomas.pointhuber@gmx.at> | 2014-03-15 19:13:57 +0100 |
---|---|---|
committer | Thomas Pointhuber <thomas.pointhuber@gmx.at> | 2014-03-15 19:13:57 +0100 |
commit | 794165d19cbf91b62d45e93c9a2f387346b89c7b (patch) | |
tree | bf432835861ee8099a7da9b6faf2a48d7a0b1a56 /searx | |
parent | 7a922b2ab8464f32ebed03d4c2b652159891fdc7 (diff) | |
download | searxng-794165d19cbf91b62d45e93c9a2f387346b89c7b.tar.gz searxng-794165d19cbf91b62d45e93c9a2f387346b89c7b.zip |
improve published Date output
Diffstat (limited to 'searx')
-rw-r--r-- | searx/webapp.py | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/searx/webapp.py b/searx/webapp.py index 9d1221fa0..5cc059044 100644 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -161,10 +161,24 @@ def index(): if 'publishedDate' in result: if result['publishedDate'].date() == datetime.now().date(): timedifference = datetime.now()-result['publishedDate'] - if timedifference.seconds < 60*60: - result['publishedDate'] = gettext(u'{0:d} minutes ago').format(timedifference.seconds/60) + minutes = int((timedifference.seconds/60)%60) + hours = int(timedifference.seconds/60/60) + if hours == 0: + if minutes == 1: + result['publishedDate'] = gettext(u'1 minute ago') + else: + result['publishedDate'] = gettext(u'{minutes} minutes ago').format(minutes=minutes) else: - result['publishedDate'] = gettext(u'{0:d} hours ago').format(timedifference.seconds/60/60) + if hours == 1: + if minutes == 1: + result['publishedDate'] = gettext(u'1 hour, 1 minute ago') + else: + result['publishedDate'] = gettext(u'1 hour, {minutes} minutes ago').format(minutes=minutes) + else: + if minutes == 1: + result['publishedDate'] = gettext(u'{hours} hours, 1 minutes ago').format(hours=hours) + else: + result['publishedDate'] = gettext(u'{hours} hours, {minutes} minutes ago').format(hours=hours, minutes=minutes) else: result['publishedDate'] = format_date(result['publishedDate']) |