Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #13592 -- Make sure the SelectDateWidget works with dates befor…

…e 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
  • Loading branch information...
commit e6ec07dc1f9070df4dab982aa4567def924bfe01 1 parent 6b2d6e1
Jannis Leidel authored May 23, 2010
2  django/forms/extras/widgets.py
@@ -7,6 +7,7 @@
7 7
 import re
8 8
 
9 9
 from django.forms.widgets import Widget, Select
  10
+from django.utils import datetime_safe
10 11
 from django.utils.dates import MONTHS
11 12
 from django.utils.safestring import mark_safe
12 13
 from django.utils.formats import get_format
@@ -100,6 +101,7 @@ def value_from_datadict(self, data, files, name):
100 101
                 except ValueError:
101 102
                     pass
102 103
                 else:
  104
+                    date_value = datetime_safe.new_date(date_value)
103 105
                     return date_value.strftime(input_format)
104 106
             else:
105 107
                 return '%s-%s-%s' % (y, m, d)
5  tests/regressiontests/forms/extra.py
@@ -435,6 +435,11 @@
435 435
 <option value="2016">2016</option>
436 436
 </select>
437 437
 
  438
+Years before 1900 work
  439
+>>> w = SelectDateWidget(years=('1899',))
  440
+>>> w.value_from_datadict({'date_year': '1899', 'date_month': '8', 'date_day': '13'}, {}, 'date')
  441
+'13-08-1899'
  442
+
438 443
 >>> translation.deactivate()
439 444
 
440 445
 # MultiWidget and MultiValueField #############################################

0 notes on commit e6ec07d

Please sign in to comment.
Something went wrong with that request. Please try again.