def datetime_to_time(x):
 if isinstance(x, datetime):
  return x.time()
 return x

def datetime_to_time ( x ) : if isinstance ( x , datetime ) : return x . time ( ) return x
convert a datetime into a time .