Skip to content

Commit

Permalink
Fix date summaries with Unicode format issues.
Browse files Browse the repository at this point in the history
This issue would show up when date formatting strings are translated
with Unicode characters (like when testing with fake Esperanto
translations).
  • Loading branch information
Peter Fogg committed May 23, 2016
1 parent 01fca6b commit c1a59cc
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lms/djangoapps/courseware/date_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def _format_date(self):
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
Expand Down Expand Up @@ -157,7 +157,9 @@ def date(self):

@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):
Expand Down

0 comments on commit c1a59cc

Please sign in to comment.