Author: ramiro Date: 2010-12-29 15:23:21 -0600 (Wed, 29 Dec 2010) New Revision: 15112
Modified: django/trunk/django/utils/feedgenerator.py Log: Fixed #10447 -- Made sure the syndication feeds helper function that returns RFC 2822-formatted datetime strings isn't affected by the current locale, removing use of strftime() because the '%a' and '%b' format specifiers are problematic in this respect. Thanks bear330 for the report and lupus for an initial patch. Modified: django/trunk/django/utils/feedgenerator.py =================================================================== --- django/trunk/django/utils/feedgenerator.py 2010-12-29 20:34:40 UTC (rev 15111) +++ django/trunk/django/utils/feedgenerator.py 2010-12-29 21:23:21 UTC (rev 15112) @@ -29,15 +29,22 @@ from django.utils.encoding import force_unicode, iri_to_uri def rfc2822_date(date): + # We can't use strftime() because it produces locale-dependant results, so + # we have to map english month and day names manually + months = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec',) + days = ('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun') + # We do this ourselves to be timezone aware, email.Utils is not tz aware. + dow = days[date.weekday()] + month = months[date.month - 1] + time_str = date.strftime('%s, %%d %s %%Y %%H:%%M:%%S ' % (dow, month)) if date.tzinfo: - time_str = date.strftime('%a, %d %b %Y %H:%M:%S ') offset = date.tzinfo.utcoffset(date) timezone = (offset.days * 24 * 60) + (offset.seconds / 60) hour, minute = divmod(timezone, 60) return time_str + "%+03d%02d" % (hour, minute) else: - return date.strftime('%a, %d %b %Y %H:%M:%S -0000') + return time_str + '-0000' def rfc3339_date(date): if date.tzinfo: -- You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-upda...@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.