Skip to content

Commit 5e047ed

Browse files
committed
Removed pre-2.6 compatibility code in date-based form fields. Refs #9459.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17870 bcc190cf-cafb-0310-a4f2-bffc1f526a37
1 parent 38115ea commit 5e047ed

File tree

1 file changed

+1
-12
lines changed

1 file changed

+1
-12
lines changed

django/forms/fields.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -341,18 +341,7 @@ def to_python(self, value):
341341
try:
342342
return self.strptime(value, format)
343343
except ValueError:
344-
if format.endswith('.%f'):
345-
# Compatibility with datetime in pythons < 2.6.
346-
# See: http://docs.python.org/library/datetime.html#strftime-and-strptime-behavior
347-
if value.count('.') != format.count('.'):
348-
continue
349-
try:
350-
datetime_str, usecs_str = value.rsplit('.', 1)
351-
usecs = int(usecs_str[:6].ljust(6, '0'))
352-
dt = datetime.datetime.strptime(datetime_str, format[:-3])
353-
return dt.replace(microsecond=usecs)
354-
except ValueError:
355-
continue
344+
continue
356345
raise ValidationError(self.error_messages['invalid'])
357346

358347
def strptime(self, value, format):

0 commit comments

Comments
 (0)