Fix (I hope) #896832 - datetimes - errors when sorting metadata

This commit is contained in:
Charles Haley 2011-11-27 13:09:39 +01:00
parent 390ed2e982
commit f31ac513d2
2 changed files with 4 additions and 3 deletions

View File

@ -305,7 +305,8 @@ class ISBNMerge(object):
ans.pubdate = r.pubdate
break
if getattr(ans.pubdate, 'year', None) == min_year:
min_date = datetime(min_year, ans.pubdate.month, ans.pubdate.day)
min_date = datetime(min_year, ans.pubdate.month, ans.pubdate.day,
tzinfo=utc_tz)
else:
min_date = datetime(min_year, 1, 2, tzinfo=utc_tz)
ans.pubdate = min_date

View File

@ -28,7 +28,7 @@ from calibre.ebooks.metadata.sources.identify import (identify,
urls_from_identifiers)
from calibre.ebooks.metadata.book.base import Metadata
from calibre.gui2 import error_dialog, NONE
from calibre.utils.date import utcnow, fromordinal, format_date
from calibre.utils.date import utcnow, fromordinal, format_date, UNDEFINED_DATE
from calibre.library.comments import comments_to_html
from calibre import force_unicode
# }}}
@ -201,7 +201,7 @@ class ResultsModel(QAbstractTableModel): # {{{
elif col == 1:
key = attrgetter('title')
elif col == 2:
key = attrgetter('pubdate')
key = lambda x: x.pubdate if x.pubdate else UNDEFINED_DATE
elif col == 3:
key = attrgetter('has_cached_cover_url')
elif key == 4: