mirror of
https://github.com/django/django.git
synced 2025-09-19 08:49:57 +00:00
Fixed #7262 - Added ISO 8601 and microsecond format string to utils.dateformat. Thanks zegor.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12058 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
ac371ccac8
commit
d981cb4e66
4 changed files with 20 additions and 1 deletions
|
@ -19,7 +19,7 @@ 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'(?<!\\)([aAbBdDfFgGhHiIjlLmMnNOPrsStTUwWyYzZ])')
|
||||
re_formatchars = re.compile(r'(?<!\\)([aAbBcdDfFgGhHiIjlLmMnNOPrsStTUuwWyYzZ])')
|
||||
re_escaped = re.compile(r'\\(.)')
|
||||
|
||||
class Formatter(object):
|
||||
|
@ -104,6 +104,11 @@ class TimeFormat(Formatter):
|
|||
"Seconds; i.e. '00' to '59'"
|
||||
return u'%02d' % self.data.second
|
||||
|
||||
def u(self):
|
||||
"Microseconds"
|
||||
return self.data.microsecond
|
||||
|
||||
|
||||
class DateFormat(TimeFormat):
|
||||
year_days = [None, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334]
|
||||
|
||||
|
@ -118,6 +123,13 @@ class DateFormat(TimeFormat):
|
|||
"Month, textual, 3 letters, lowercase; e.g. 'jan'"
|
||||
return MONTHS_3[self.data.month]
|
||||
|
||||
def c(self):
|
||||
"""
|
||||
ISO 8601 Format
|
||||
Example : '2008-01-02T10:30:00.000123'
|
||||
"""
|
||||
return self.data.isoformat(' ')
|
||||
|
||||
def d(self):
|
||||
"Day of the month, 2 digits with leading zeros; i.e. '01' to '31'"
|
||||
return u'%02d' % self.data.day
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue