Ticket #9762: rfc2822.diff
File rfc2822.diff, 1.6 KB (added by , 16 years ago) |
---|
-
django/utils/dateformat.py
17 17 from django.utils.encoding import force_unicode 18 18 from calendar import isleap, monthrange 19 19 import re, time 20 from email.utils import formatdate 20 21 21 22 re_formatchars = re.compile(r'(?<!\\)([aAbBdDfFgGhHiIjlLmMnNOPrsStTUwWyYzZ])') 22 23 re_escaped = re.compile(r'\\(.)') … … 170 171 return u"%+03d%02d" % (seconds // 3600, (seconds // 60) % 60) 171 172 172 173 def r(self): 173 "RFC 2822 formatted date; e.g. 'Thu, 21 Dec 2000 16:01:07 +0200'" 174 return self.format('D, j M Y H:i:s O') 174 "RFC 2822 formatted date; e.g. 'Thu, 21 Dec 2000 16:01:07 +0200'" 175 # solution taken from http://bugs.python.org/issue665194 until 176 # Python addresses implements this feature 177 timestamp = time.mktime(self.data.timetuple()) 178 return formatdate(timestamp) 175 179 176 180 def S(self): 177 181 "English ordinal suffix for the day of the month, 2 characters; i.e. 'st', 'nd', 'rd' or 'th'" -
tests/regressiontests/dateformat/tests.py
69 69 70 70 >>> format(the_future, r'Y') 71 71 u'2100' 72 73 >>> from django.conf import settings 74 >>> settings.LANGUAGE_CODE='es' 75 >>> translation.activate('es') 76 >>> no_tz or format(my_birthday, 'r') == 'Sun, 8 Jul 1979 22:00:00 +0100' 77 True 72 78 """ 73 79 74 80 from django.utils import dateformat, translation