def convert_datetime(obj):
 if ((not PY2) and isinstance(obj, (bytes, bytearray))):
  obj = obj.decode('ascii')
 m = DATETIME_RE.match(obj)
 if (not m):
  return convert_date(obj)
 try:
  groups = list(m.groups())
  groups[(-1)] = _convert_second_fraction(groups[(-1)])
  return datetime.datetime(*[int(x) for x in groups])
 except ValueError:
  return convert_date(obj)

def convert_datetime ( obj ) : if ( ( not PY2 ) and isinstance ( obj , ( bytes , bytearray ) ) ) : obj = obj . decode ( 'ascii' ) m = DATETIME_RE . match ( obj ) if ( not m ) : return convert_date ( obj ) try : groups = list ( m . groups ( ) ) groups [ ( - 1 ) ] = _convert_second_fraction ( groups [ ( - 1 ) ] ) return datetime . datetime ( * [ int ( x ) for x in groups ] ) except ValueError : return convert_date ( obj )
returns a datetime or timestamp column value as a datetime object: .