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)

This commit is contained in:
Kovid Goyal 2017-07-11 09:04:32 +05:30
parent 9bf00e26bb
commit af6159bc55
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 5 additions and 4 deletions

View File

@ -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))

View File

@ -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 = ''