diff --git a/src/calibre/__init__.py b/src/calibre/__init__.py index d96f48f9a5..f105db8879 100644 --- a/src/calibre/__init__.py +++ b/src/calibre/__init__.py @@ -544,7 +544,7 @@ def strftime(fmt, t=None): ans = None if iswindows: if isinstance(fmt, unicode): - fmt = fmt.encode('mbcs') + fmt = fmt.encode('mbcs', 'replace') fmt = fmt.replace(b'%e', b'%#d') ans = plugins['winutil'][0].strftime(fmt, t) else: diff --git a/src/calibre/web/feeds/templates.py b/src/calibre/web/feeds/templates.py index 3ed689fe59..a3fe823333 100644 --- a/src/calibre/web/feeds/templates.py +++ b/src/calibre/web/feeds/templates.py @@ -11,7 +11,7 @@ from lxml.html.builder import HTML, HEAD, TITLE, STYLE, DIV, BODY, \ STRONG, BR, SPAN, A, HR, UL, LI, H2, H3, IMG, P as PT, \ TABLE, TD, TR -from calibre import preferred_encoding, strftime, isbytestring +from calibre import strftime, isbytestring def CLASS(*args, **kwargs): # class is a reserved word in Python @@ -88,8 +88,6 @@ class IndexTemplate(Template): def _generate(self, title, masthead, datefmt, feeds, extra_css=None, style=None): self.IS_HTML = False - if isinstance(datefmt, unicode): - datefmt = datefmt.encode(preferred_encoding) date = strftime(datefmt) head = HEAD(TITLE(title)) if style: @@ -245,11 +243,7 @@ class NavBarTemplate(Template): class TouchscreenIndexTemplate(Template): def _generate(self, title, masthead, datefmt, feeds, extra_css=None, style=None): - self.IS_HTML = False - - if isinstance(datefmt, unicode): - datefmt = datefmt.encode(preferred_encoding) date = '%s, %s %s, %s' % (strftime('%A'), strftime('%B'), strftime('%d').lstrip('0'), strftime('%Y')) masthead_p = etree.Element("p") masthead_p.set("style","text-align:center")