diff --git a/src/calibre/db/tables.py b/src/calibre/db/tables.py index 9b9ff4e9e0..f71abe2a6d 100644 --- a/src/calibre/db/tables.py +++ b/src/calibre/db/tables.py @@ -29,6 +29,12 @@ def _c_convert_timestamp(val): return None try: ret = _c_speedup.parse_date(val.strip()) + except AttributeError: + # If a value like 2001 is stored in the column, apsw will return it as + # an int + if isinstance(val, (int, float)): + return datetime(int(val), 1, 1, tzinfo=tzoffset(None, 0)).astimezone(local_tz) + ret = None except: ret = None if ret is None: