CSV Catalogs: Output all custom datetime columns in the local timezone to match the format for builtin columns

This commit is contained in:
Kovid Goyal 2014-10-09 08:22:45 +05:30
parent e828f7d41d
commit 713153a965

View File

@ -14,6 +14,7 @@ from calibre.customize.conversion import DummyReporter
class CSV_XML(CatalogPlugin): class CSV_XML(CatalogPlugin):
'CSV/XML catalog generator' 'CSV/XML catalog generator'
Option = namedtuple('Option', 'option, default, dest, action, help') Option = namedtuple('Option', 'option, default, dest, action, help')
@ -88,7 +89,7 @@ class CSV_XML(CatalogPlugin):
if not len(data): if not len(data):
log.error("\nNo matching database entries for search criteria '%s'" % opts.search_text) log.error("\nNo matching database entries for search criteria '%s'" % opts.search_text)
#raise SystemExit(1) # raise SystemExit(1)
# Get the requested output fields as a list # Get the requested output fields as a list
fields = self.get_output_fields(db, opts) fields = self.get_output_fields(db, opts)
@ -135,7 +136,7 @@ class CSV_XML(CatalogPlugin):
elif field == 'isbn': elif field == 'isbn':
# Could be 9, 10 or 13 digits, with hyphens, possibly ending in 'X' # Could be 9, 10 or 13 digits, with hyphens, possibly ending in 'X'
item = u'%s' % re.sub(r'[^\dX-]', '', item) item = u'%s' % re.sub(r'[^\dX-]', '', item)
elif field in ['pubdate', 'timestamp']: elif fm.get(field, {}).get('datatype') == 'datetime':
item = isoformat(item, as_utc=False) item = isoformat(item, as_utc=False)
elif field == 'comments': elif field == 'comments':
item = item.replace(u'\r\n', u' ') item = item.replace(u'\r\n', u' ')