Mon, 14 Jul 2008 12:31:15 -0400 <me@nikosapi.org>

Merge patch to fix bug #122 (Day of week Released date not computed correctly)

	* src/gpodder/libpodcasts.py: use rfc822.mktime_tz() to convert
	timestamps from feedparser's _parse_date() function to seconds from
	the epoch (in UTC instead of the local timezone)
	* src/gpodder/util.py: fix util.format_date() so that when it reports
	'Today', it means the timestamp is from after 00:00 local time



git-svn-id: svn://svn.berlios.de/gpodder/trunk@770 b0d088ad-0a06-0410-aad2-9ed5178a7e87
This commit is contained in:
Nick 2008-07-14 16:46:59 +00:00
parent ee18e3bb02
commit a2bf6c0577
3 changed files with 25 additions and 9 deletions

View File

@ -1,3 +1,12 @@
Mon, 14 Jul 2008 12:31:15 -0400 <me@nikosapi.org>
Merge patch to fix bug #122 (Day of week Released date not computed correctly)
* src/gpodder/libpodcasts.py: use rfc822.mktime_tz() to convert
timestamps from feedparser's _parse_date() function to seconds from
the epoch (in UTC instead of the local timezone)
* src/gpodder/util.py: fix util.format_date() so that when it reports
'Today', it means the timestamp is from after 00:00 local time
Mon, 14 Jul 2008 12:21:37 -0400 <me@nikosapi.org>
Merge patch to fix bug #125 (Deleting a podcast while checking for new
episodes allows a second concurrent sync.)

View File

@ -53,6 +53,7 @@ import urllib
import urlparse
import time
import datetime
import rfc822
import md5
import xml.dom.minidom
import feedparser
@ -134,7 +135,7 @@ class podcastChannel(object):
self.description = util.remove_html_tags(c.feed.subtitle)
if hasattr(c.feed, 'updated_parsed') and c.feed.updated_parsed is not None:
self.pubDate = time.mktime(c.feed.updated_parsed)
self.pubDate = rfc822.mktime_tz(c.feed.updated_parsed+(0,))
else:
self.pubDate = time.time()
if hasattr( c.feed, 'image'):
@ -443,7 +444,7 @@ class podcastItem(object):
episode.description = util.remove_html_tags( entry.get( 'summary', entry.get( 'link', entry.get( 'title', ''))))
episode.guid = entry.get( 'id', '')
if entry.get( 'updated_parsed', None):
episode.pubDate = time.mktime(entry.updated_parsed)
episode.pubDate = rfc822.mktime_tz(entry.updated_parsed+(0,))
if episode.title == '':
log( 'Warning: Episode has no title, adding anyways.. (Feed Is Buggy!)', sender = episode)

View File

@ -281,17 +281,23 @@ def format_date(timestamp):
return None
seconds_in_a_day = 60*60*24
today = time.localtime()[:3]
yesterday = time.localtime(time.time() - seconds_in_a_day)[:3]
timestamp_date = time.localtime(timestamp)[:3]
if timestamp_date == today:
return _('Today')
elif timestamp_date == yesterday:
return _('Yesterday')
try:
diff = int((time.time()+1)/seconds_in_a_day) - int(timestamp/seconds_in_a_day)
diff = int( (time.time() - timestamp)/seconds_in_a_day )
except:
log('Warning: Cannot convert "%s" to date.', timestamp, traceback=True)
return None
if diff == 0:
return _('Today')
elif diff == 1:
return _('Yesterday')
elif diff < 7:
if diff < 7:
# Weekday name
return str(datetime.datetime.fromtimestamp(timestamp).strftime('%A'))
else: