import time


def display_rate_limit(tag, limit):
    """Display rate limit if it isn't at maximum; return available count for convenience"""
    if limit["remaining"] != limit["limit"]:
        print(limit["remaining"], "out of", limit["limit"], tag, "queries available")
        reset_time = limit["reset"]
        print("   Will reset in", reset_time - time.time(), "seconds, at", time.ctime(reset_time))
    return limit["remaining"]