import requests
from bs4 import BeautifulSoup


def datetime_extractor(url):
    """
    Returns start and the end datetime values of a PR.

    Parameters:
        url (url): URL to every Pull Request.

    Returns:
        End (datetime): date and time when the PR was opened for the first time.
        Start (datetime): date and time when the PR was closed.
    """
    datetime=[]
    r=requests.get(url)
    soup=BeautifulSoup(r.content,'html.parser')
    div_tags=soup.findAll('div',class_="TimelineItem-body")
    for _,i in enumerate(div_tags):
        for a in i.findChildren('a'):
            for rt in a.findChildren('relative-time',class_="no-wrap"):
                datetime.append(rt['datetime'])
    return max(datetime),min(datetime)