'Validates that the input can be converted to a datetime. Returns a
Python datetime.datetime object.'

def to_python(self, value):

    if (value in validators.EMPTY_VALUES):
        return None
    if isinstance(value, datetime.datetime):
        return value
    if isinstance(value, datetime.date):
        return datetime.datetime(value.year, value.month, value.day)
    if isinstance(value, list):
        if (len(value) != 2):
            raise ValidationError(self.error_messages['invalid'])
        if ((value[0] in validators.EMPTY_VALUES) and (value[1] in validators.EMPTY_VALUES)):
            return None
        value = ('%s    %s' % tuple(value))
    for format in (self.input_formats or formats.get_format('DATETIME_INPUT_FORMATS')):
        try:
            return datetime.datetime(*time.strptime(value, format)[:6])
        except ValueError:
            continue
    raise ValidationError(self.error_messages['invalid'])
