def format_time_delta(delta):
    """
    Given a time delta object, convert it into a nice, human readable string.
    For example, given 290 seconds, return 4m 50s.
    """
    d = delta.days
    h = delta.seconds / 3600
    m = (delta.seconds % 3600) / 60
    s = delta.seconds % 60

    if d > 0:
        return '%sd %sh' % (d, h)
    elif h > 0:
        return '%sh %sm' % (h, m)
    else:
        return '%sm %ss' % (m, s)