From af6159bc55ccd71fa0c8f19eb35aae03ffcbeb45 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 11 Jul 2017 09:04:32 +0530 Subject: [PATCH] Conversion: WHen inserting the publication year in the metadata jacket, do so in the local time zone, so it matches what is displayed in the main calibre program. Fixes #1703439 [wrong pubdate on the jacket if set to 01/01/YYYY](https://bugs.launchpad.net/calibre/+bug/1703439) --- src/calibre/ebooks/conversion/plumber.py | 4 ++-- src/calibre/ebooks/oeb/transforms/jacket.py | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/calibre/ebooks/conversion/plumber.py b/src/calibre/ebooks/conversion/plumber.py index 5cad96873f..8131e997f4 100644 --- a/src/calibre/ebooks/conversion/plumber.py +++ b/src/calibre/ebooks/conversion/plumber.py @@ -610,7 +610,7 @@ OptionRecommendation(name='language', OptionRecommendation(name='pubdate', recommended_value=None, level=OptionRecommendation.LOW, - help=_('Set the publication date.')), + help=_('Set the publication date (assumed to be in the local timezone, unless the timezone is explicitly specified)')), OptionRecommendation(name='timestamp', recommended_value=None, level=OptionRecommendation.LOW, @@ -895,7 +895,7 @@ OptionRecommendation(name='search_replace', continue elif x in ('timestamp', 'pubdate'): try: - val = parse_date(val, assume_utc=x=='pubdate') + val = parse_date(val, assume_utc=x=='timestamp') except: self.log.exception(_('Failed to parse date/time') + ' ' + unicode(val)) diff --git a/src/calibre/ebooks/oeb/transforms/jacket.py b/src/calibre/ebooks/oeb/transforms/jacket.py index 633e2b6d1a..cd3f8f9265 100644 --- a/src/calibre/ebooks/oeb/transforms/jacket.py +++ b/src/calibre/ebooks/oeb/transforms/jacket.py @@ -17,7 +17,7 @@ from calibre.constants import iswindows from calibre.ebooks.BeautifulSoup import BeautifulSoup from calibre.ebooks.oeb.base import XPath, XHTML_NS, XHTML, xml2text, urldefrag from calibre.library.comments import comments_to_html -from calibre.utils.date import is_date_undefined +from calibre.utils.date import is_date_undefined, as_local_time from calibre.utils.icu import sort_key from calibre.ebooks.chardet import strip_encoding_declarations from calibre.ebooks.metadata import fmt_sidx, rating_to_stars @@ -220,7 +220,8 @@ def render_jacket(mi, output_profile, if is_date_undefined(mi.pubdate): pubdate = '' else: - pubdate = strftime(u'%Y', mi.pubdate.timetuple()) + dt = as_local_time(mi.pubdate) + pubdate = strftime(u'%Y', dt.timetuple()) except: pubdate = ''