mirror of https://github.com/django/django.git
Fixed #3488: Added "b" option to date format filter. Thanks, Gary Wilson.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@4647 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
0e683f6da4
commit
28ad156f10
|
@ -16,7 +16,7 @@ from django.utils.tzinfo import LocalTimezone
|
|||
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 @@ class DateFormat(TimeFormat):
|
|||
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
|
||||
|
|
|
@ -645,6 +645,7 @@ Available format strings:
|
|||
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.
|
||||
|
|
|
@ -17,6 +17,8 @@ r"""
|
|||
'07'
|
||||
>>> format(my_birthday, 'M')
|
||||
'Jul'
|
||||
>>> format(my_birthday, 'b')
|
||||
'jul'
|
||||
>>> format(my_birthday, 'n')
|
||||
'7'
|
||||
>>> format(my_birthday, 'N')
|
||||
|
|
Loading…
Reference in New Issue