Ticket #9459: datetime-microseconds-py24.patch
File datetime-microseconds-py24.patch, 2.6 KB (added by , 14 years ago) |
---|
-
django/conf/global_settings.py
346 346 # * Note that these format strings are different from the ones to display dates 347 347 DATETIME_INPUT_FORMATS = ( 348 348 '%Y-%m-%d %H:%M:%S', # '2006-10-25 14:30:59' 349 '%Y-%m-%d %H:%M:%S.%f', # '2006-10-25 14:30:59.000200' 349 350 '%Y-%m-%d %H:%M', # '2006-10-25 14:30' 350 351 '%Y-%m-%d', # '2006-10-25' 351 352 '%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 … … 418 419 return None 419 420 value = '%s %s' % tuple(value) 420 421 for format in self.input_formats or formats.get_format('DATETIME_INPUT_FORMATS'): 422 if format.endswith('.%f') and sys.version_info[:2]<=(2,6): 423 if not value.count('.')==1: 424 continue 425 try: 426 value, usecs = value.rsplit('.', 1) 427 usecs = int(usecs) 428 return datetime.datetime(*time.strptime(value, format[:-3])[:6]+(usecs,)) 429 except ValueError: 430 continue 421 431 try: 422 432 return datetime.datetime(*time.strptime(value, format)[:6]) 423 433 except ValueError: -
tests/regressiontests/forms/fields.py
323 323 self.assertEqual(datetime.datetime(2006, 10, 25, 14, 30, 59), f.clean(datetime.datetime(2006, 10, 25, 14, 30, 59))) 324 324 self.assertEqual(datetime.datetime(2006, 10, 25, 14, 30, 59, 200), f.clean(datetime.datetime(2006, 10, 25, 14, 30, 59, 200))) 325 325 self.assertEqual(datetime.datetime(2006, 10, 25, 14, 30, 45), f.clean('2006-10-25 14:30:45')) 326 self.assertEqual(datetime.datetime(2006, 10, 25, 14, 30, 45, 200), f.clean('2006-10-25 14:30:45.000200')) 326 327 self.assertEqual(datetime.datetime(2006, 10, 25, 14, 30), f.clean('2006-10-25 14:30:00')) 327 328 self.assertEqual(datetime.datetime(2006, 10, 25, 14, 30), f.clean('2006-10-25 14:30')) 328 329 self.assertEqual(datetime.datetime(2006, 10, 25, 0, 0), f.clean('2006-10-25'))