Fix year out-of-range problem in format_date (bug 537)

If datetime.datetime.fromtimestamp() does not work,
simply return "None" in gpodder.util's format_date().

Thanks to phq for the fix suggestion.
This commit is contained in:
Thomas Perl 2009-08-24 01:13:10 +02:00
parent 01fcdb8633
commit 7f88f06bc9
1 changed files with 7 additions and 2 deletions

View File

@ -392,12 +392,17 @@ def format_date(timestamp):
log('Warning: Cannot convert "%s" to date.', timestamp, traceback=True)
return None
try:
timestamp = datetime.datetime.fromtimestamp(timestamp)
except:
return None
if diff < 7:
# Weekday name
return str(datetime.datetime.fromtimestamp(timestamp).strftime('%A'))
return str(timestamp.strftime('%A'))
else:
# Locale's appropriate date representation
return str(datetime.datetime.fromtimestamp(timestamp).strftime('%x'))
return str(timestamp.strftime('%x'))
def format_filesize(bytesize, use_si_units=False, digits=2):