﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
29089	Redundant date parsing in SelectDateWidget.format_value()	Carlton Gibson	nobody	"`SelectDateWidget.format_value()` contains a block to parse a string value into year, month and day components. 

The current implementation first attempts to parse `value` as a `datetime`. 

Regardless of the outcome here it then parses `value` again against against a regex. 

Current implementation: 

https://github.com/django/django/blob/d4bbd3f41882104156cf9f2b02cb13376a59489d/django/forms/widgets.py#L1006-L1018

{{{
        elif isinstance(value, str):
            if settings.USE_L10N:
                input_format = get_format('DATE_INPUT_FORMATS')[0]
                try:
                    d = datetime.datetime.strptime(value, input_format)
                except ValueError:
                    pass
                else:
                    year, month, day = d.year, d.month, d.day
            match = self.date_re.match(value)
            if match:
                year, month, day = [int(val) for val in match.groups()]
        return {'year': year, 'month': month, 'day': day}
}}}

With default settings `input_format` is (essentially) the same as the `date_re`. We end up doing the work twice. 

Should we not skip the `re.match` block if the `strptime` approach already succeeded?"	Bug	closed	Forms	dev	Normal	fixed			Ready for checkin	1	0	0	0	0	0
