def format_time(time):
    """
    Format seconds into human readable format.

    Parameters
    ----------
    time : float
        Time specified in seconds

    Returns
    -------
    str
        Formated time.
    """
    mins, seconds = divmod(int(time), 60)
    hours, minutes = divmod(mins, 60)
    if hours > 0:
        return '{:0>2d}:{:0>2d}:{:0>2d}'.format(hours, minutes, seconds)
    elif minutes > 0:
        return '{:0>2d}:{:0>2d}'.format(minutes, seconds)
    elif seconds > 0:
        return '{:.0f} sec'.format(seconds)
    elif time >= 0.001:
        return '{:.0f} ms'.format(time * 1000.0)
    elif time >= 1e-06:
        return '{:.0f} μs'.format(time * 1000000.0)
    return '{:.0f} ns'.format(time * 1000000000.0)
