diff options
| author | Adam Tauber <asciimoo@gmail.com> | 2014-03-18 18:20:10 +0100 |
|---|---|---|
| committer | Adam Tauber <asciimoo@gmail.com> | 2014-03-18 18:20:10 +0100 |
| commit | 018a14431bd3612db4e8840ce24f3e60026ece0f (patch) | |
| tree | 18c7f0ed489c0c0f206ac1f0a191b1ce0ab045b2 /searx/webapp.py | |
| parent | faed14b2c691746ba6cf98d164a5e6b1ca3ee4c9 (diff) | |
| parent | 993271bed30e24c7ae1e0f63b64e030829206f27 (diff) | |
Merge pull request #57 from pointhi/results
improving publishDate extraction and output of it
Diffstat (limited to 'searx/webapp.py')
| -rw-r--r-- | searx/webapp.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/searx/webapp.py b/searx/webapp.py index 28d046cd8..44865345a 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,6 +168,7 @@ 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': |