Fix #896832 (datetimes - errors when sorting metadata)

This commit is contained in:
Kovid Goyal 2011-11-27 17:49:08 +05:30
parent f55e5efa2a
commit 6a84d88d0d

View File

@ -28,7 +28,8 @@ 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, as_utc)
from calibre.library.comments import comments_to_html
from calibre import force_unicode
# }}}
@ -201,7 +202,12 @@ class ResultsModel(QAbstractTableModel): # {{{
elif col == 1:
key = attrgetter('title')
elif col == 2:
key = attrgetter('pubdate')
def dategetter(x):
x = getattr(x, 'pubdate', None)
if x is None:
x = UNDEFINED_DATE
return as_utc(x)
key = dategetter
elif col == 3:
key = attrgetter('has_cached_cover_url')
elif key == 4: