Ticket #10447: rfc2822_date.patch
File rfc2822_date.patch, 1.3 KB (added by , 15 years ago) |
---|
-
feedgenerator.py
25 25 from django.utils.encoding import force_unicode, iri_to_uri 26 26 27 27 def rfc2822_date(date): 28 # We can't use strftime() because it produces locale-dependant results, so we have to map english month and day names manually 29 months = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec',) 30 days = ('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat',) 31 28 32 # We do this ourselves to be timezone aware, email.Utils is not tz aware. 29 33 if date.tzinfo: 30 time_str = date.strftime( '%a, %d %b%Y %H:%M:%S ')34 time_str = date.strftime(days[date.weekday()] + ', %d ' + months[date.month - 1] + ' %Y %H:%M:%S ') 31 35 offset = date.tzinfo.utcoffset(date) 32 36 timezone = (offset.days * 24 * 60) + (offset.seconds / 60) 33 37 hour, minute = divmod(timezone, 60) 34 38 return time_str + "%+03d%02d" % (hour, minute) 35 39 else: 36 return date.strftime('%a, %d %b %Y %H:%M:%S -0000') 40 time_str = date.strftime(days[date.weekday()] + ', %d ' + months[date.month - 1] + ' %Y %H:%M:%S -0000') 41 return time_str 37 42 38 43 def rfc3339_date(date): 39 44 if date.tzinfo: