def format_time(total_seconds, hours_fmt=False, precise=False, hours_pad=True):
    """
    Convert total_seconds float into a string of the form "02:33:44". total_seconds amounts
    greater than a day will still use hours notation.

    Output is either in minutes "00:00" formatting or hours "00:00:00" formatting.
    Not possible to only produce seconds or days+, etc.

    total_seconds: float
    hours_fmt: True = Force hours output. False = Force minutes output.
    precise: Use floating point value for seconds.
    hours_pad: Pad hours field to 2 digits.
    """

    if precise:
        # .0f is to suppress float output if precise=True.
        # if precise=True, the .format() calls below will be passed floats
        # from divmod.
        # :02.0f = pad to 2 digits, no decimal places.
        # :06.3f = pad to 2 digits, three decimal places (6 chars total)
        fmt_str_mins = '{:02.0f}:{:06.3f}'
        fmt_str_hours = '{:02.0f}:{:02.0f}:{:06.3f}'
    else:
        fmt_str_mins = '{:02}:{:02}'
        if hours_pad:
            fmt_str_hours = '{:02}:{:02}:{:02}'
        else:
            fmt_str_hours = '{}:{:02}:{:02}'

    total_sec = total_seconds if precise else int(total_seconds)
    total_mins, secs = divmod(total_sec, 60)

    ret = ''
    if hours_fmt:
        hours, mins = divmod(int(total_mins), 60)
        ret = fmt_str_hours.format(hours, mins, secs)
    else:
        ret = fmt_str_mins.format(total_mins, secs)

    return ret