mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #892438 (error reading books from nook)
This commit is contained in:
commit
2d6d6eb76f
@ -6,11 +6,12 @@ Created on 4 Jun 2010
|
||||
|
||||
from base64 import b64encode, b64decode
|
||||
import json, traceback
|
||||
from datetime import datetime, time
|
||||
|
||||
from calibre.ebooks.metadata.book import SERIALIZABLE_FIELDS
|
||||
from calibre.constants import filesystem_encoding, preferred_encoding
|
||||
from calibre.library.field_metadata import FieldMetadata
|
||||
from calibre.utils.date import parse_date, isoformat, UNDEFINED_DATE
|
||||
from calibre.utils.date import parse_date, isoformat, UNDEFINED_DATE, local_tz
|
||||
from calibre.utils.magick import Image
|
||||
from calibre import isbytestring
|
||||
|
||||
@ -22,7 +23,13 @@ def string_to_datetime(src):
|
||||
return parse_date(src)
|
||||
|
||||
def datetime_to_string(dateval):
|
||||
if dateval is None or dateval == UNDEFINED_DATE:
|
||||
if dateval is None:
|
||||
return "None"
|
||||
if not isinstance(dateval, datetime):
|
||||
dateval = datetime.combine(dateval, time())
|
||||
if hasattr(dateval, 'tzinfo') and dateval.tzinfo is None:
|
||||
dateval = dateval.replace(tzinfo=local_tz)
|
||||
if dateval <= UNDEFINED_DATE:
|
||||
return "None"
|
||||
return isoformat(dateval)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user