def format_time(sec):
    """ Re-formats time duration in seconds (*sec*) into more easily readable 
        form, where (days,) hours, minutes, and seconds are explicitly shown.
        Returns the new duration as a formatted string.
    """
    import time
    if sec < 864000:
        return time.strftime('%H:%M:%S', time.gmtime(sec))
    else:
        days = int(sec / 864000)
        secs = sec % 864000
        return str(days) + 'd, ' + time.strftime('%H:%M:%S', time.gmtime(secs))
