Fixed #13592 -- Make sure the SelectDateWidget works with dates before 1900 when localization is enabled. Thanks for the report and patch, magnus.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@13301 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
6b2d6e1833
commit
e6ec07dc1f
|
@ -7,6 +7,7 @@ import datetime
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from django.forms.widgets import Widget, Select
|
from django.forms.widgets import Widget, Select
|
||||||
|
from django.utils import datetime_safe
|
||||||
from django.utils.dates import MONTHS
|
from django.utils.dates import MONTHS
|
||||||
from django.utils.safestring import mark_safe
|
from django.utils.safestring import mark_safe
|
||||||
from django.utils.formats import get_format
|
from django.utils.formats import get_format
|
||||||
|
@ -100,6 +101,7 @@ class SelectDateWidget(Widget):
|
||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
|
date_value = datetime_safe.new_date(date_value)
|
||||||
return date_value.strftime(input_format)
|
return date_value.strftime(input_format)
|
||||||
else:
|
else:
|
||||||
return '%s-%s-%s' % (y, m, d)
|
return '%s-%s-%s' % (y, m, d)
|
||||||
|
|
|
@ -435,6 +435,11 @@ USE_L10N tests
|
||||||
<option value="2016">2016</option>
|
<option value="2016">2016</option>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
Years before 1900 work
|
||||||
|
>>> w = SelectDateWidget(years=('1899',))
|
||||||
|
>>> w.value_from_datadict({'date_year': '1899', 'date_month': '8', 'date_day': '13'}, {}, 'date')
|
||||||
|
'13-08-1899'
|
||||||
|
|
||||||
>>> translation.deactivate()
|
>>> translation.deactivate()
|
||||||
|
|
||||||
# MultiWidget and MultiValueField #############################################
|
# MultiWidget and MultiValueField #############################################
|
||||||
|
|
Loading…
Reference in New Issue