def __fromrelative__(self, timestr):
        timestr = " {} ".format(timestr)

        if timestr.find(" ago ") == -1 and timestr.find(" in ") == -1:
            return None

        future = timestr.find(" in ") != -1
        coef = 1 if future else -1
        dati = datetime.datetime.utcnow()

        # timedelta does not support years
        if timestr.find(" year") != -1:
            try:
                match = re.match(r".*?([0-9]+?) year", timestr)
                assert match is not None
                dati = dati.replace(
                    year=dati.year + int(match.group(1)) * coef
                )
            except __HOLE__:
                pass

        # ... or months
        if timestr.find(" month") != -1:
            try:
                match = re.match(r".*?([0-9]+?) month", timestr)
                assert match is not None
                months = int(match.group(1))
                newyear = dati.year + int(((dati.month - 1) + months * coef) / 12)
                newmonth = (((dati.month - 1) + months * coef) % 12) + 1
                newday = dati.day
                while newday > calendar.monthrange(newyear, newmonth)[1]:
                    newday -= 1
                dati = dati.replace(year=newyear, month=newmonth, day=newday)
            except AssertionError:
                pass

        delta = {
            "weeks": 0,
            "days": 0,
            "hours": 0,
            "minutes": 0,
            "seconds": 0
        }

        for key in delta.keys():
            if timestr.find(" " + key[:-1]) != -1:
                try:
                    match = re.match(
                        re.compile(".*?([0-9]+?) " + key[:-1]),
                        timestr
                    )
                    assert match is not None
                    delta[key] += int(match.group(1))
                except AssertionError:
                    pass

        if not future:
            for key in delta.keys():
                delta[key] *= -1

        dati = dati + datetime.timedelta(**delta)

        return _mktime(dati.timetuple())
dataset/ETHPy150Open KoffeinFlummi/Chronyk/chronyk/chronyk.py/Chronyk.__fromrelative__