From 0613b43364a02ac34773d503350acddaba316657 Mon Sep 17 00:00:00 2001 From: Charles Haley Date: Fri, 12 Nov 2021 11:42:31 +0000 Subject: [PATCH] Bug 1950758: Book details: Adjustments to search when clicking on a datetime column Search never uses the time and timezone so suppress them from the search string. --- src/calibre/ebooks/metadata/book/render.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/calibre/ebooks/metadata/book/render.py b/src/calibre/ebooks/metadata/book/render.py index 5886b91729..eac13ab426 100644 --- a/src/calibre/ebooks/metadata/book/render.py +++ b/src/calibre/ebooks/metadata/book/render.py @@ -16,7 +16,7 @@ from calibre.constants import filesystem_encoding from calibre.library.comments import comments_to_html, markdown from calibre.utils.icu import sort_key from calibre.utils.formatter import EvalFormatter -from calibre.utils.date import is_date_undefined +from calibre.utils.date import is_date_undefined, format_date from calibre.utils.localization import calibre_langcode_to_name from calibre.utils.serialize import json_dumps from polyglot.binary import as_hex_unicode @@ -281,9 +281,15 @@ def mi_to_html( aval = getattr(mi, field) if is_date_undefined(aval): continue - val = '%s' % ( - search_action_with_data(field, str(aval), book_id, None, original_value=val), a( - _('Click to see books with {0}: {1} (derived from {2})').format( + aval = format_date(aval, 'yyyy-MM-dd') + if val == aval: + val = '%s' % ( + search_action_with_data(field, str(aval), book_id, None, original_value=val), a( + _('Click to see books with {0}: {1}').format(metadata['name'] or field, val)), val) + else: + val = '%s' % ( + search_action_with_data(field, str(aval), book_id, None, original_value=val), a( + _('Click to see books with {0}: {1} (derived from {2})').format( metadata['name'] or field, aval, val)), val) elif metadata['datatype'] == 'text' and metadata['is_multiple']: try: