mirror of
https://github.com/django/django.git
synced 2025-09-19 08:49:57 +00:00
Fixed #14570 -- Added new date format character for alternative month names using the new context capabilities. Also add context to Associated Press style month names (refs #9988). Thanks to Claude and shell_dweller.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@14899 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
dc8c4f0879
commit
7292af8542
3 changed files with 24 additions and 3 deletions
|
@ -14,12 +14,12 @@ Usage:
|
|||
import re
|
||||
import time
|
||||
import calendar
|
||||
from django.utils.dates import MONTHS, MONTHS_3, MONTHS_AP, WEEKDAYS, WEEKDAYS_ABBR
|
||||
from django.utils.dates import MONTHS, MONTHS_3, MONTHS_ALT, MONTHS_AP, WEEKDAYS, WEEKDAYS_ABBR
|
||||
from django.utils.tzinfo import LocalTimezone
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.utils.encoding import force_unicode
|
||||
|
||||
re_formatchars = re.compile(r'(?<!\\)([aAbBcdDfFgGhHiIjlLmMnNOPrsStTUuwWyYzZ])')
|
||||
re_formatchars = re.compile(r'(?<!\\)([aAbBcdDEfFgGhHiIjlLmMnNOPrsStTUuwWyYzZ])')
|
||||
re_escaped = re.compile(r'\\(.)')
|
||||
|
||||
class Formatter(object):
|
||||
|
@ -138,6 +138,10 @@ class DateFormat(TimeFormat):
|
|||
"Day of the week, textual, 3 letters; e.g. 'Fri'"
|
||||
return WEEKDAYS_ABBR[self.data.weekday()]
|
||||
|
||||
def E(self):
|
||||
"Alternative month names as required by some locales. Proprietary extension."
|
||||
return MONTHS_ALT[self.data.month]
|
||||
|
||||
def F(self):
|
||||
"Month, textual, long; e.g. 'January'"
|
||||
return MONTHS[self.data.month]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue