on master help sign in
fix bug, to display publishDate with timezone without error
commitfd86bf8189683aee72b934c8dd7544aa362a0728 authorThomas Pointhuber <thomas.pointhuber@gmx.at> dateTue 18 Mar 2014, 13:19 (13 years ago) parent6f49bd8
1 file changed+3−4
searx/webapp.py+3−4
searx/webapp.py+3−4
@@ -159,8 +159,8 @@ def index():
159159
160160 # TODO, check if timezone is calculated right
161161 if 'publishedDate' in result:
162− if result['publishedDate'] >= datetime.now() - timedelta(days=1):
163− timedifference = datetime.now() - result['publishedDate']
162+ if result['publishedDate'].replace(tzinfo=None) >= datetime.now() - timedelta(days=1):
163+ timedifference = datetime.now() - result['publishedDate'].replace(tzinfo=None)
164164 minutes = int((timedifference.seconds / 60) % 60)
165165 hours = int(timedifference.seconds / 60 / 60)
166166 if hours == 0:
@@ -168,8 +168,7 @@ def index():
168168 else:
169169 result['publishedDate'] = gettext(u'{hours} hour(s), {minutes} minute(s) ago').format(hours=hours, minutes=minutes) # noqa
170170 else:
171− # TODO using right timezone
172− result['pubdate'] = result['publishedDate'].strftime('%a, %d %b %Y %H:%M:%S +0000')
171+ result['pubdate'] = result['publishedDate'].strftime('%a, %d %b %Y %H:%M:%S %z')
173172 result['publishedDate'] = format_date(result['publishedDate'])
174173
175174 if search.request_data.get('format') == 'json':