From c1a59cc0b33b9e021148adaa955ef6146b562952 Mon Sep 17 00:00:00 2001 From: Peter Fogg Date: Mon, 23 May 2016 11:15:09 -0400 Subject: [PATCH] Fix date summaries with Unicode format issues. This issue would show up when date formatting strings are translated with Unicode characters (like when testing with fake Esperanto translations). --- lms/djangoapps/courseware/date_summary.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lms/djangoapps/courseware/date_summary.py b/lms/djangoapps/courseware/date_summary.py index c589a6bedc..c0fd9daad0 100644 --- a/lms/djangoapps/courseware/date_summary.py +++ b/lms/djangoapps/courseware/date_summary.py @@ -111,7 +111,7 @@ class DateSummary(object): date_format = _(u"{relative} ago - {absolute}") if date_has_passed else _(u"in {relative} - {absolute}") return date_format.format( relative=relative_date, - absolute=self.date.strftime(self.date_format), + absolute=self.date.strftime(self.date_format.encode('utf-8')).decode('utf-8'), ) @property @@ -157,7 +157,9 @@ class TodaysDate(DateSummary): @property def title(self): - return _(u'Today is {date}').format(date=datetime.now(pytz.UTC).strftime(self.date_format)) + return _(u'Today is {date}').format( + date=datetime.now(pytz.UTC).strftime(self.date_format.encode('utf-8')).decode('utf-8') + ) class CourseStartDate(DateSummary):