Ticket #7014: newforms-dates-1900.diff
File newforms-dates-1900.diff, 2.0 KB (added by , 17 years ago) |
---|
-
django/newforms/fields.py
281 281 return value 282 282 for format in self.input_formats: 283 283 try: 284 returndatetime.date(*time.strptime(value, format)[:3])284 value = datetime.date(*time.strptime(value, format)[:3]) 285 285 except ValueError: 286 286 continue 287 if value.year < 1900: 288 break 289 return value 287 290 raise ValidationError(self.error_messages['invalid']) 288 291 289 292 DEFAULT_TIME_INPUT_FORMATS = ( … … 359 362 value = '%s %s' % tuple(value) 360 363 for format in self.input_formats: 361 364 try: 362 returndatetime.datetime(*time.strptime(value, format)[:6])365 value = datetime.datetime(*time.strptime(value, format)[:6]) 363 366 except ValueError: 364 367 continue 368 if value.year < 1900: 369 break 370 return value 365 371 raise ValidationError(self.error_messages['invalid']) 366 372 367 373 class RegexField(CharField): -
tests/regressiontests/forms/fields.py
442 442 Traceback (most recent call last): 443 443 ... 444 444 ValidationError: [u'Enter a valid date.'] 445 >>> f.clean('1/1/1801') 446 Traceback (most recent call last): 447 ... 448 ValidationError: [u'Enter a valid date.'] 445 449 >>> f.clean(None) 446 450 Traceback (most recent call last): 447 451 ... … … 562 566 Traceback (most recent call last): 563 567 ... 564 568 ValidationError: [u'Enter a valid date/time.'] 569 >>> f.clean('10/10/1801 14:30') 570 Traceback (most recent call last): 571 ... 572 ValidationError: [u'Enter a valid date/time.'] 565 573 566 574 DateField accepts an optional input_formats parameter: 567 575 >>> f = DateTimeField(input_formats=['%Y %m %d %I:%M %p'])