def time_ago(x):
 delta = timedelta(weeks=1)
 if ((datetime.utcnow() - x) > delta):
  return x.strftime('%b %d, %Y')
 else:
  date_array = date.distance_of_time_in_words(x, datetime.utcnow()).replace(',', '').split(' ')
  return ('~%s %s ago' % (date_array[0], date_array[1]))

def time_ago ( x ) : delta = timedelta ( weeks = 1 ) if ( ( datetime . utcnow ( ) - x ) > delta ) : return x . strftime ( '%b %d, %Y' ) else : date_array = date . distance_of_time_in_words ( x , datetime . utcnow ( ) ) . replace ( ',' , '' ) . split ( ' ' ) return ( '~%s %s ago' % ( date_array [ 0 ] , date_array [ 1 ] ) )
convert a datetime to a string .