diff options
author | Cqoicebordel <Cqoicebordel@users.noreply.github.com> | 2014-12-08 00:51:46 +0100 |
---|---|---|
committer | Cqoicebordel <Cqoicebordel@users.noreply.github.com> | 2014-12-08 00:51:46 +0100 |
commit | c2e88339f7bb84e719e943b427a9afcdd84981aa (patch) | |
tree | 2e6a505fcc4d414165f16e221ee6373452ab4094 /searx/webapp.py | |
parent | 9517f7a6e775aded6f1673f4a991594b08750467 (diff) | |
download | searxng-c2e88339f7bb84e719e943b427a9afcdd84981aa.tar.gz searxng-c2e88339f7bb84e719e943b427a9afcdd84981aa.zip |
Add pubdate
Add pubdate with a good format, against publishedDate.
Diffstat (limited to 'searx/webapp.py')
-rw-r--r-- | searx/webapp.py | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/searx/webapp.py b/searx/webapp.py index 57a16ff4f..9f09f51f5 100644 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -294,10 +294,9 @@ def index(): # TODO, check if timezone is calculated right if 'publishedDate' in result: - if result['publishedDate'].replace(tzinfo=None)\ - >= datetime.now() - timedelta(days=1): - timedifference = datetime.now() - result['publishedDate']\ - .replace(tzinfo=None) + result['pubdate'] = result['publishedDate'].strftime('%Y-%m-%d %H:%M:%S%z') + if result['publishedDate'].replace(tzinfo=None) >= datetime.now() - timedelta(days=1): + timedifference = datetime.now() - result['publishedDate'].replace(tzinfo=None) minutes = int((timedifference.seconds / 60) % 60) hours = int(timedifference.seconds / 60 / 60) if hours == 0: @@ -305,8 +304,6 @@ def index(): else: result['publishedDate'] = gettext(u'{hours} hour(s), {minutes} minute(s) ago').format(hours=hours, minutes=minutes) # noqa else: - result['pubdate'] = result['publishedDate']\ - .strftime('%a, %d %b %Y %H:%M:%S %z') result['publishedDate'] = format_date(result['publishedDate']) if search.request_data.get('format') == 'json': |