def _format_timedelta(timedelta):
    """
    Return hh:mm:ss, or mm:ss if the amount of hours is zero.
    """
    result = '{0}'.format(timedelta).split('.')[0]
    if result.startswith('0:'):
        result = result[2:]
    return result
