mirror of
https://github.com/django/django.git
synced 2025-01-31 04:40:13 +00:00
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
This commit is contained in:
parent
38115ea742
commit
5e047ed859
@ -341,18 +341,7 @@ class BaseTemporalField(Field):
|
|||||||
try:
|
try:
|
||||||
return self.strptime(value, format)
|
return self.strptime(value, format)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
if format.endswith('.%f'):
|
continue
|
||||||
# Compatibility with datetime in pythons < 2.6.
|
|
||||||
# See: http://docs.python.org/library/datetime.html#strftime-and-strptime-behavior
|
|
||||||
if value.count('.') != format.count('.'):
|
|
||||||
continue
|
|
||||||
try:
|
|
||||||
datetime_str, usecs_str = value.rsplit('.', 1)
|
|
||||||
usecs = int(usecs_str[:6].ljust(6, '0'))
|
|
||||||
dt = datetime.datetime.strptime(datetime_str, format[:-3])
|
|
||||||
return dt.replace(microsecond=usecs)
|
|
||||||
except ValueError:
|
|
||||||
continue
|
|
||||||
raise ValidationError(self.error_messages['invalid'])
|
raise ValidationError(self.error_messages['invalid'])
|
||||||
|
|
||||||
def strptime(self, value, format):
|
def strptime(self, value, format):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user