def format_time_to_HMS( num_seconds ):
    """
    Formats 'num_seconds' in H:MM:SS format.  If the argument is a string,
    then it checks for a colon.  If it has a colon, the string is returned
    untouched. Otherwise it assumes seconds and converts to an integer before
    changing to H:MM:SS format.
    """
    if type(num_seconds) == type(''):
        if ':' in num_seconds:
            return num_seconds

    secs = int(num_seconds)

    nhrs = secs // 3600
    secs = secs % 3600
    nmin = secs // 60
    nsec = secs % 60

    hms = str(nhrs)+':'
    if nmin < 10: hms += '0'
    hms += str(nmin)+':'
    if nsec < 10: hms += '0'
    hms += str(nsec)

    return hms