Author: jacob
Date: 2007-02-28 10:18:55 -0600 (Wed, 28 Feb 2007)
New Revision: 4647

Modified:
   django/trunk/django/utils/dateformat.py
   django/trunk/docs/templates.txt
   django/trunk/tests/regressiontests/dateformat/tests.py
Log:
Fixed #3488: Added "b" option to date format filter. Thanks, Gary Wilson.

Modified: django/trunk/django/utils/dateformat.py
===================================================================
--- django/trunk/django/utils/dateformat.py     2007-02-28 15:39:53 UTC (rev 
4646)
+++ django/trunk/django/utils/dateformat.py     2007-02-28 16:18:55 UTC (rev 
4647)
@@ -16,7 +16,7 @@
 from calendar import isleap, monthrange
 import re, time
 
-re_formatchars = re.compile(r'(?<!\\)([aABdDfFgGhHiIjlLmMnNOPrsStTUwWyYzZ])')
+re_formatchars = re.compile(r'(?<!\\)([aAbBdDfFgGhHiIjlLmMnNOPrsStTUwWyYzZ])')
 re_escaped = re.compile(r'\\(.)')
 
 class Formatter(object):
@@ -110,6 +110,10 @@
         if hasattr(self.data, 'hour') and not self.timezone:
             self.timezone = LocalTimezone(dt)
 
+    def b(self):
+        "Month, textual, 3 letters, lowercase; e.g. 'jan'"
+        return MONTHS_3[self.data.month]
+
     def d(self):
         "Day of the month, 2 digits with leading zeros; i.e. '01' to '31'"
         return '%02d' % self.data.day

Modified: django/trunk/docs/templates.txt
===================================================================
--- django/trunk/docs/templates.txt     2007-02-28 15:39:53 UTC (rev 4646)
+++ django/trunk/docs/templates.txt     2007-02-28 16:18:55 UTC (rev 4647)
@@ -645,6 +645,7 @@
                       output, because this includes periods
                       to match Associated Press style.)
     A                 ``'AM'`` or ``'PM'``.                     ``'AM'``
+    b                 Month, textual, 3 letters, lowercase.     ``'jan'``
     B                 Not implemented.
     d                 Day of the month, 2 digits with           ``'01'`` to 
``'31'``
                       leading zeros.

Modified: django/trunk/tests/regressiontests/dateformat/tests.py
===================================================================
--- django/trunk/tests/regressiontests/dateformat/tests.py      2007-02-28 
15:39:53 UTC (rev 4646)
+++ django/trunk/tests/regressiontests/dateformat/tests.py      2007-02-28 
16:18:55 UTC (rev 4647)
@@ -17,6 +17,8 @@
 '07'
 >>> format(my_birthday, 'M')
 'Jul'
+>>> format(my_birthday, 'b')
+'jul'
 >>> format(my_birthday, 'n')
 '7'
 >>> format(my_birthday, 'N')


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to