

def approximate_age(self, from_stamp, to_stamp=None, precision=2):
    'Calculate the relative time from given timestamp to another given (epoch) or now.'
    if (to_stamp is None):
        to_stamp = time.time()
    rem = (to_stamp - from_stamp)

    def divide(rem, mod):
        return ((rem % mod), int((rem // mod)))

    def subtract(rem, div):
        n = int((rem // div))
        return (n, (rem - (n * div)))
    (seconds, rem) = divide(days, 60)
    (minutes, rem) = divide(rem, 60)
    (hours, days) = divide(rem, 24)
    (years, days) = subtract(days, 365)
    (months, days) = subtract(days, 30)
    (weeks, days) = subtract(days, 7)
    magnitudes = []
    first = None
    values = locals()
    for (i, magnitude) in enumerate(('years', 'months', 'weeks', 'days', 'hours', 'minutes', 'seconds')):
        v = int(values[magnitude])
        if (v == 0):
            continue
        s = ('%s %s' % (v, magnitude))
        if (v == 1):
            s = s[:(- 1)]
        if (first is None):
            first = i
        elif ((first + precision) <= i):
            break
        magnitudes.append(s)
    return ', '.join(magnitudes)

dataset/ETHPy150Open FichteFoll/FileHistory/file_history.py OpenRecentlyClosedFileCommand.approximate_age/VarMisuse@124/171 `rem`->`days`