diff options
| author | Thomas Pointhuber <thomas.pointhuber@gmx.at> | 2014-03-18 13:19:23 +0100 |
|---|---|---|
| committer | Thomas Pointhuber <thomas.pointhuber@gmx.at> | 2014-03-18 13:19:23 +0100 |
| commit | fd86bf8189683aee72b934c8dd7544aa362a0728 (patch) | |
| tree | fd28cd7e5cfe33e347ad073cb4bb3a4e9c629be2 | |
| parent | 6f49bd8f08fbd52c67e21477fc2d21553d8220d7 (diff) | |
fix bug, to display publishDate with timezone without error
| -rw-r--r-- | searx/webapp.py | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/searx/webapp.py b/searx/webapp.py index d06c58f32..a4c05a9e9 100644 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -159,8 +159,8 @@ def index(): # TODO, check if timezone is calculated right if 'publishedDate' in result: - if result['publishedDate'] >= datetime.now() - timedelta(days=1): - timedifference = datetime.now() - result['publishedDate'] + 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: @@ -168,8 +168,7 @@ def index(): else: result['publishedDate'] = gettext(u'{hours} hour(s), {minutes} minute(s) ago').format(hours=hours, minutes=minutes) # noqa else: - # TODO using right timezone - result['pubdate'] = result['publishedDate'].strftime('%a, %d %b %Y %H:%M:%S +0000') + 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': |