from datetime import datetime


async def get_pypi_version_time(session, name):
    """
    Get the last release and it's date from pypi.
    """
    url = f"https://pypi.org/pypi/{name}/json"

    async with session.get(url) as resp:
        info = (await resp.json())
    version = info["info"]["version"]
    time = datetime.fromisoformat(info["releases"][version][0]["upload_time"])
    return version, time