Ticket #7262: microsecond.patch
File microsecond.patch, 2.9 KB (added by , 16 years ago) |
---|
-
django/utils/dateformat.py
old new 18 18 from calendar import isleap, monthrange 19 19 import re, time 20 20 21 re_formatchars = re.compile(r'(?<!\\)([aAbB dDfFgGhHiIjlLmMnNOPrsStTUwWyYzZ])')21 re_formatchars = re.compile(r'(?<!\\)([aAbBcdDfFgGhHiIjlLmMnNOPrsStTUuwWyYzZ])') 22 22 re_escaped = re.compile(r'\\(.)') 23 23 24 24 class Formatter(object): … … 103 103 "Seconds; i.e. '00' to '59'" 104 104 return u'%02d' % self.data.second 105 105 106 def u(self): 107 "Microseconds" 108 return self.data.microsecond 109 110 106 111 class DateFormat(TimeFormat): 107 112 year_days = [None, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334] 108 113 … … 117 122 "Month, textual, 3 letters, lowercase; e.g. 'jan'" 118 123 return MONTHS_3[self.data.month] 119 124 125 def c(self): 126 """ 127 ISO 8601 Format 128 Example : '2008-01-02 10:30:00.000123' 129 """ 130 return self.data.isoformat(' ') 131 120 132 def d(self): 121 133 "Day of the month, 2 digits with leading zeros; i.e. '01' to '31'" 122 134 return u'%02d' % self.data.day -
docs/templates.txt
old new 916 916 A ``'AM'`` or ``'PM'``. ``'AM'`` 917 917 b Month, textual, 3 letters, lowercase. ``'jan'`` 918 918 B Not implemented. 919 c ISO 8601 Format ``2008-01-02 10:30:00.000123`` 919 920 d Day of the month, 2 digits with ``'01'`` to ``'31'`` 920 921 leading zeros. 921 922 D Day of the week, textual, 3 letters. ``'Fri'`` … … 952 953 month, 2 characters. 953 954 t Number of days in the given month. ``28`` to ``31`` 954 955 T Time zone of this machine. ``'EST'``, ``'MDT'`` 956 u Microseconds ``0`` to ``999999`` 955 957 U Not implemented. 956 958 w Day of the week, digits without ``'0'`` (Sunday) to ``'6'`` (Saturday) 957 959 leading zeros. -
tests/regressiontests/dateformat/tests.py
old new 5 5 u'p.m.' 6 6 >>> format(my_birthday, 'A') 7 7 u'PM' 8 >>> format(timestamp, 'c') 9 u'2008-05-19 11:45:23.123456' 8 10 >>> format(my_birthday, 'd') 9 11 u'08' 10 12 >>> format(my_birthday, 'j') … … 39 41 True 40 42 >>> no_tz or format(my_birthday, 'U') == '300531600' 41 43 True 44 >>> format(timestamp, 'u') 45 u'123456' 42 46 >>> format(my_birthday, 'w') 43 47 u'0' 44 48 >>> format(my_birthday, 'W') … … 88 92 summertime = datetime.datetime(2005, 10, 30, 1, 00) 89 93 wintertime = datetime.datetime(2005, 10, 30, 4, 00) 90 94 the_future = datetime.datetime(2100, 10, 25, 0, 00) 95 timestamp = datetime.datetime(2008, 5, 19, 11, 45, 23, 123456)