diff --git a/src/calibre/gui2/metadata/single_download.py b/src/calibre/gui2/metadata/single_download.py index 70b32a78c6..1c0f3c8042 100644 --- a/src/calibre/gui2/metadata/single_download.py +++ b/src/calibre/gui2/metadata/single_download.py @@ -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: