summaryrefslogtreecommitdiff
path: root/django/utils/dateformat.py
diff options
context:
space:
mode:
authorJannis Leidel <jannis@leidel.info>2010-01-01 21:39:26 +0000
committerJannis Leidel <jannis@leidel.info>2010-01-01 21:39:26 +0000
commitd981cb4e66245bbe4c5a91e8a5d3747fcf9a6a88 (patch)
treea64c0abd312e59aaa2bfd7c41a95e242376a3af8 /django/utils/dateformat.py
parentac371ccac8dada9f97fd66fc9780c085e7f04470 (diff)
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
Diffstat (limited to 'django/utils/dateformat.py')
-rw-r--r--django/utils/dateformat.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/django/utils/dateformat.py b/django/utils/dateformat.py
index b2ea71228c..13cc2c7a81 100644
--- a/django/utils/dateformat.py
+++ b/django/utils/dateformat.py
@@ -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