diff --git a/src/calibre/gui2/library/delegates.py b/src/calibre/gui2/library/delegates.py index 1924778c3c..f65406ba54 100644 --- a/src/calibre/gui2/library/delegates.py +++ b/src/calibre/gui2/library/delegates.py @@ -247,6 +247,8 @@ class DateDelegate(QStyledItemDelegate, UpdateEditorGeometry): # {{{ val = now() else: val = index.data(Qt.ItemDataRole.EditRole) + if is_date_undefined(val): + val = now() editor.setDateTime(val) # }}} diff --git a/src/calibre/utils/date.py b/src/calibre/utils/date.py index ae7c4e4d8d..8b7492e8f5 100644 --- a/src/calibre/utils/date.py +++ b/src/calibre/utils/date.py @@ -157,6 +157,8 @@ safeyear = lambda x: min(max(x, MINYEAR), MAXYEAR) def qt_to_dt(qdate_or_qdatetime, as_utc=True): o = qdate_or_qdatetime + if o is None: + return UNDEFINED_DATE if hasattr(o, 'toUTC'): # QDateTime o = o.toUTC()