def humanize_seconds(total_seconds,
                     frmt='{hours:02d}:{minutes:02d}:{seconds:02d}',
                     negative_frmt=None):

    """Given time in int(seconds), return a string representing the time.
    If negative_frmt is not given, a negative sign is prepended to frmt
    and the result is wrapped in a <span> with the "negative-time" class.
    """

    if negative_frmt is None:
        negative_frmt = '<span class="negative-time">-{0}</span>'.format(frmt)

    seconds = abs(int(total_seconds))

    mapping = {
        'hours': seconds // 3600,
        'minutes': seconds % 3600 // 60,
        'seconds': seconds % 3600 % 60,
    }

    if total_seconds < 0:
        result = negative_frmt.format(**mapping)

    else:
        result = frmt.format(**mapping)

    return result