summaryrefslogtreecommitdiff
path: root/searx/webapp.py
diff options
context:
space:
mode:
Diffstat (limited to 'searx/webapp.py')
-rw-r--r--searx/webapp.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/searx/webapp.py b/searx/webapp.py
index fdb6568b4..2f7f131c8 100644
--- a/searx/webapp.py
+++ b/searx/webapp.py
@@ -26,6 +26,7 @@ import json
import cStringIO
import os
+from datetime import datetime, timedelta
from itertools import chain
from flask import (
Flask, request, render_template, url_for, Response, make_response,
@@ -156,6 +157,17 @@ def index():
if engine in favicons:
result['favicon'] = engine
+ # TODO, check if timezone is calculated right
+ if 'publishedDate' in result:
+ if result['publishedDate'].date() == datetime.now().date():
+ timedifference = datetime.now()-result['publishedDate']
+ if timedifference.seconds < 60*60:
+ result['publishedDate'] = '{0:d} minutes ago'.format(timedifference.seconds/60)
+ else:
+ result['publishedDate'] = '{0:d} hours ago'.format(timedifference.seconds/60/60)
+ else:
+ result['publishedDate'] = result['publishedDate'].strftime('%d.%m.%Y')
+
if search.request_data.get('format') == 'json':
return Response(json.dumps({'query': search.query,
'results': search.results}),