fix: Align custom updated date columns with title page metadata

Write custom datetime columns for datePublished, dateUpdated, and dateCreated from the raw datetime values tracked on the book object instead of the formatted all_metadata strings.

This keeps Calibre custom date columns aligned with the metadata used to generate the FanFicFare title page and avoids format-layer mismatches when the plugin updates existing books.
This commit is contained in:
Victor239 2026-03-21 11:18:17 +00:00
parent 36e2183d45
commit 15b9532b79

View file

@ -2387,6 +2387,13 @@ class FanFicFarePlugin(InterfaceAction):
except Exception as e:
raise_exception(meta,val,label,e)
def _get_raw_custom_date_value(self, book, meta):
return {
'datePublished': book.get('pubdate'),
'dateUpdated': book.get('updatedate'),
'dateCreated': book.get('timestamp'),
}.get(meta)
def update_metadata(self, db, book_id, book, mi, options):
oldmi = db.get_metadata(book_id,index_is_id=True)
if prefs['keeptags']:
@ -2480,7 +2487,13 @@ class FanFicFarePlugin(InterfaceAction):
continue
label = coldef['label']
if coldef['datatype'] in ('enumeration','comments','datetime','series'):
self.set_custom(db, book_id, meta, book['all_metadata'][meta], label, commit=False)
val = book['all_metadata'][meta]
if coldef['datatype'] == 'datetime':
val = self._get_raw_custom_date_value(book, meta)
if not val:
logger.debug("No raw datetime value for %s, skipping custom column(%s) update."%(meta,coldef['name']))
continue
self.set_custom(db, book_id, meta, val, label, commit=False)
elif coldef['datatype'] == 'text':
joined_val = book['all_metadata'][meta]
# 'Contains names' custom columns need & separators.
@ -2559,6 +2572,8 @@ class FanFicFarePlugin(InterfaceAction):
val = sum(items)
else:
val = unicode(val).replace(",","")
elif coldef['datatype'] == 'datetime':
val = self._get_raw_custom_date_value(book, meta)
else:
val = val
if coldef['datatype'] == 'bool':
@ -2569,7 +2584,7 @@ class FanFicFarePlugin(InterfaceAction):
else:
val = None # for tri-state 'booleans'. Yes/No/Null
# logger.debug("setting 'r' or 'added':meta:%s label:%s val:%s"%(meta,label,val))
if val != '':
if val not in ('', None):
self.set_custom(db, book_id, meta, val, label=label, commit=False)
if flag == 'a':