From 8822e8f865b9f226f6fe3be5521dcbd94892e3de Mon Sep 17 00:00:00 2001 From: tomi Date: Mon, 10 Mar 2008 17:16:27 +0000 Subject: [PATCH] timezone errors. git-svn-id: https://jerakeen.org/svn/tomi/Projects/Shelf@3859 ab05c693-d3d1-0310-8e8b-e1346d90d6a5 --- Utilities.py | 2 +- providers/FeedProvider.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Utilities.py b/Utilities.py index 9f0e811..7fbf384 100644 --- a/Utilities.py +++ b/Utilities.py @@ -150,7 +150,7 @@ def time_ago_in_words(from_time, include_seconds=False): """ Like distance_of_time_in_words, but where ``to_time`` is fixed to ``datetime.now()``. """ - ago = distance_of_time_in_words(from_time, datetime.now(), include_seconds) + ago = distance_of_time_in_words(from_time, datetime.utcnow(), include_seconds) # TODO - think about these. The output from the function is Too Damn Long, is all. ago = re.sub(r'^about ', '~', ago ) ago = re.sub(r'minute', 'min', ago ) diff --git a/providers/FeedProvider.py b/providers/FeedProvider.py index 145f09d..21257ca 100644 --- a/providers/FeedProvider.py +++ b/providers/FeedProvider.py @@ -123,12 +123,14 @@ def htmlForFeed( self, url, feed, stale = False ): for item in filter( lambda item: "link" in item, entries )[0:4]: if 'published_parsed' in item: date = item.published_parsed elif 'updated_parsed' in item: date = item.updated_parsed + else: date = None if date: #html += u'%s'%( time.strftime("%b %d", date ) ) ago = time_ago_in_words(date) + " ago" html += u'%s'%ago title = 'title' in item and item.title or "untitled" + try: html += u'

%s

'%( item.link, title ) except UnicodeDecodeError: