def convert_mysql_timestamp(timestamp):
 if ((not PY2) and isinstance(timestamp, (bytes, bytearray))):
  timestamp = timestamp.decode('ascii')
 if (timestamp[4] == '-'):
  return convert_datetime(timestamp)
 timestamp += ('0' * (14 - len(timestamp)))
 (year, month, day, hour, minute, second) = (int(timestamp[:4]), int(timestamp[4:6]), int(timestamp[6:8]), int(timestamp[8:10]), int(timestamp[10:12]), int(timestamp[12:14]))
 try:
  return datetime.datetime(year, month, day, hour, minute, second)
 except ValueError:
  return None

def convert_mysql_timestamp ( timestamp ) : if ( ( not PY2 ) and isinstance ( timestamp , ( bytes , bytearray ) ) ) : timestamp = timestamp . decode ( 'ascii' ) if ( timestamp [ 4 ] == '-' ) : return convert_datetime ( timestamp ) timestamp += ( '0' * ( 14 - len ( timestamp ) ) ) ( year , month , day , hour , minute , second ) = ( int ( timestamp [ : 4 ] ) , int ( timestamp [ 4 : 6 ] ) , int ( timestamp [ 6 : 8 ] ) , int ( timestamp [ 8 : 10 ] ) , int ( timestamp [ 10 : 12 ] ) , int ( timestamp [ 12 : 14 ] ) ) try : return datetime . datetime ( year , month , day , hour , minute , second ) except ValueError : return None
convert a mysql timestamp to a timestamp object .