Ticket #9459: datetime-microseconds-py25.patch
File datetime-microseconds-py25.patch, 2.7 KB (added by , 14 years ago) |
---|
-
django/conf/global_settings.py
350 350 # * Note that these format strings are different from the ones to display dates 351 351 DATETIME_INPUT_FORMATS = ( 352 352 '%Y-%m-%d %H:%M:%S', # '2006-10-25 14:30:59' 353 '%Y-%m-%d %H:%M:%S.%f', # '2006-10-25 14:30:59.000200' 353 354 '%Y-%m-%d %H:%M', # '2006-10-25 14:30' 354 355 '%Y-%m-%d', # '2006-10-25' 355 356 '%m/%d/%Y %H:%M:%S', # '10/25/2006 14:30:59' -
django/forms/fields.py
5 5 import datetime 6 6 import os 7 7 import re 8 import sys 8 9 import time 9 10 import urlparse 10 11 import warnings … … 401 402 raise ValidationError(self.error_messages['invalid']) 402 403 value = '%s %s' % tuple(value) 403 404 for format in self.input_formats or formats.get_format('DATETIME_INPUT_FORMATS'): 405 if format.endswith('.%f') and sys.version_info<=(2,6) and value.count('.')==1: 406 try: 407 value, usecs = value.rsplit('.', 1) 408 usecs = int(usecs) 409 return datetime.datetime(*time.strptime(value, format[:-3])[:6]+(usecs,)) 410 except ValueError: 411 continue 404 412 try: 405 return datetime.datetime (*time.strptime(value, format)[:6])413 return datetime.datetime.strptime(value, format) 406 414 except ValueError: 407 415 continue 408 416 raise ValidationError(self.error_messages['invalid']) -
tests/regressiontests/forms/fields.py
320 320 self.assertEqual(datetime.datetime(2006, 10, 25, 14, 30, 59), f.clean(datetime.datetime(2006, 10, 25, 14, 30, 59))) 321 321 self.assertEqual(datetime.datetime(2006, 10, 25, 14, 30, 59, 200), f.clean(datetime.datetime(2006, 10, 25, 14, 30, 59, 200))) 322 322 self.assertEqual(datetime.datetime(2006, 10, 25, 14, 30, 45), f.clean('2006-10-25 14:30:45')) 323 self.assertEqual(datetime.datetime(2006, 10, 25, 14, 30, 45, 200), f.clean('2006-10-25 14:30:45.000200')) 323 324 self.assertEqual(datetime.datetime(2006, 10, 25, 14, 30), f.clean('2006-10-25 14:30:00')) 324 325 self.assertEqual(datetime.datetime(2006, 10, 25, 14, 30), f.clean('2006-10-25 14:30')) 325 326 self.assertEqual(datetime.datetime(2006, 10, 25, 0, 0), f.clean('2006-10-25'))