def _relative_timestamp(dt):
 delta = (datetime.utcnow() - dt)
 diff = ((delta.microseconds + ((delta.seconds + ((delta.days * 24) * 3600)) * 1000000.0)) / 1000000.0)
 if (diff < 45):
  return '{} second{}'.format(int(diff), ('' if (int(diff) == 1) else 's'))
 elif (diff < 90):
  return 'a minute'
 elif (diff < 2700):
  return '{} minutes'.format(int(max((diff / 60), 2)))
 elif (diff < 5400):
  return 'an hour'
 elif (diff < 79200):
  return '{} hours'.format(int(max((diff / 3600), 2)))
 elif (diff < 129600):
  return 'a day'
 elif (diff < 2592000):
  return '{} days'.format(int(max((diff / 86400), 2)))
 else:
  return None

def _relative_timestamp ( dt ) : delta = ( datetime . utcnow ( ) - dt ) diff = ( ( delta . microseconds + ( ( delta . seconds + ( ( delta . days * 24 ) * 3600 ) ) * 1000000.0 ) ) / 1000000.0 ) if ( diff < 45 ) : return '{} second{}' . format ( int ( diff ) , ( '' if ( int ( diff ) == 1 ) else 's' ) ) elif ( diff < 90 ) : return 'a minute' elif ( diff < 2700 ) : return '{} minutes' . format ( int ( max ( ( diff / 60 ) , 2 ) ) ) elif ( diff < 5400 ) : return 'an hour' elif ( diff < 79200 ) : return '{} hours' . format ( int ( max ( ( diff / 3600 ) , 2 ) ) ) elif ( diff < 129600 ) : return 'a day' elif ( diff < 2592000 ) : return '{} days' . format ( int ( max ( ( diff / 86400 ) , 2 ) ) ) else : return None
format a human readable relative time for timestamps up to 30 days old .