def seconds_to_string(seconds):
    """
    Format a time given in seconds to a string HH:MM:SS. Used for the
    'leg time/cum. time' columns of the table view.
    """
    hours, seconds = divmod(int(seconds), 3600)
    minutes, seconds = divmod(seconds, 60)
    return f"{hours:02d}:{minutes:02d}:{seconds:02d}"