diff options
| author | Ramiro Morales <cramm0@gmail.com> | 2011-06-10 18:43:29 +0000 |
|---|---|---|
| committer | Ramiro Morales <cramm0@gmail.com> | 2011-06-10 18:43:29 +0000 |
| commit | c43d15b3b329c0dcd2bfeda9b647641f1dcfeaf6 (patch) | |
| tree | 55726d159a3dfac266a784bd18b8abe83e52965f /django/forms/fields.py | |
| parent | 0e03a504bf28c727283bcabbff0f4dc63feaf573 (diff) | |
More removal of poorly legible constructs to workaround Python 2.4 shortcomings.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16363 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/forms/fields.py')
| -rw-r--r-- | django/forms/fields.py | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/django/forms/fields.py b/django/forms/fields.py index dd23b12e5c..67564218ab 100644 --- a/django/forms/fields.py +++ b/django/forms/fields.py @@ -6,9 +6,7 @@ import copy import datetime import os import re -import time import urlparse -import warnings from decimal import Decimal, DecimalException try: from cStringIO import StringIO @@ -20,7 +18,6 @@ from django.core import validators from django.utils import formats from django.utils.translation import ugettext_lazy as _ from django.utils.encoding import smart_unicode, smart_str, force_unicode -from django.utils.functional import lazy # Provide this import for backwards compatibility. from django.core.validators import EMPTY_VALUES @@ -344,7 +341,8 @@ class BaseTemporalField(Field): try: datetime_str, usecs_str = value.rsplit('.', 1) usecs = int(usecs_str) - return datetime.datetime(*time.strptime(datetime_str, format[:-3])[:6]+(usecs,)) + dt = datetime.datetime.strptime(datetime_str, format[:-3]) + return dt.replace(microsecond=usecs) except ValueError: continue raise ValidationError(self.error_messages['invalid']) @@ -373,7 +371,7 @@ class DateField(BaseTemporalField): return super(DateField, self).to_python(value) def strptime(self, value, format): - return datetime.date(*time.strptime(value, format)[:3]) + return datetime.datetime.strptime(value, format).date() class TimeField(BaseTemporalField): widget = TimeInput @@ -394,7 +392,7 @@ class TimeField(BaseTemporalField): return super(TimeField, self).to_python(value) def strptime(self, value, format): - return datetime.time(*time.strptime(value, format)[3:6]) + return datetime.datetime.strptime(value, format).time() class DateTimeField(BaseTemporalField): widget = DateTimeInput |
