Fixed Python2.4 incompatibility introduced in r13041: datetime.strptime classmethod was added in 2.5.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@13078 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
02ffb6f1dd
commit
7fc25715d6
|
@ -2,6 +2,7 @@
|
||||||
Extra HTML Widget classes
|
Extra HTML Widget classes
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import time
|
||||||
import datetime
|
import datetime
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
@ -46,7 +47,11 @@ class SelectDateWidget(Widget):
|
||||||
if settings.USE_L10N:
|
if settings.USE_L10N:
|
||||||
try:
|
try:
|
||||||
input_format = get_format('DATE_INPUT_FORMATS')[0]
|
input_format = get_format('DATE_INPUT_FORMATS')[0]
|
||||||
v = datetime.datetime.strptime(value, input_format)
|
# Python 2.4 compatibility:
|
||||||
|
# v = datetime.datetime.strptime(value, input_format)
|
||||||
|
# would be clearer, but datetime.strptime was added in
|
||||||
|
# Python 2.5
|
||||||
|
v = datetime.datetime(*(time.strptime(value, input_format)[0:6]))
|
||||||
year_val, month_val, day_val = v.year, v.month, v.day
|
year_val, month_val, day_val = v.year, v.month, v.day
|
||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
|
|
Loading…
Reference in New Issue