Ticket #13592: selectdatewidget.patch

File selectdatewidget.patch, 1.3 KB (added by magnus, 14 years ago)
  • django/forms/extras/widgets.py

     
    77import re
    88
    99from django.forms.widgets import Widget, Select
     10from django.utils import datetime_safe
    1011from django.utils.dates import MONTHS
    1112from django.utils.safestring import mark_safe
    1213from django.utils.formats import get_format
     
    100101                except ValueError:
    101102                    pass
    102103                else:
     104                    date_value = datetime_safe.new_date(date_value)
    103105                    return date_value.strftime(input_format)
    104106            else:
    105107                return '%s-%s-%s' % (y, m, d)
  • tests/regressiontests/forms/extra.py

     
    435435<option value="2016">2016</option>
    436436</select>
    437437
     438Years 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
    438443>>> translation.deactivate()
    439444
    440445# MultiWidget and MultiValueField #############################################
Back to Top