Ticket #12986: 12986.diff

File 12986.diff, 1.2 KB (added by walteralini, 14 years ago)
  • django/forms/extras/widgets.py

     
    4343        except AttributeError:
    4444            year_val = month_val = day_val = None
    4545            if isinstance(value, basestring):
    46                 match = RE_DATE.match(value)
    47                 if match:
    48                     year_val, month_val, day_val = [int(v) for v in match.groups()]
    49 
     46                if settings.USE_L10N:
     47                    input_format = get_format('DATE_INPUT_FORMATS')[0]
     48                    try:
     49                        val = datetime.datetime.strptime(value, input_format)
     50                        year_val, month_val, day_val = val.year, val.month, val.day
     51                    except ValueError:
     52                        pass                   
     53                else:
     54                    match = RE_DATE.match(value)
     55                    if match:
     56                        year_val, month_val, day_val = [int(v) for v in match.groups()]
    5057        choices = [(i, i) for i in self.years]
    5158        year_html = self.create_select(name, self.year_field, value, year_val, choices)
    5259        choices = MONTHS.items()
Back to Top