def _pretty_relative_time(time_diff_secs):
    """Originally from: https://stackoverflow.com/questions/1551382/user-friendly-time-format-in-python
    Each tuple in the sequence gives the name of a unit, and the number of
    previous units which go into it.
    """
    weeks_per_month = 365.242 / 12 / 7
    intervals = [('minute', 60), ('hour', 60), ('day', 24), ('week', 7), (
        'month', weeks_per_month), ('year', 12)]
    unit, number = 'second', abs(time_diff_secs)
    for new_unit, ratio in intervals:
        new_number = float(number) / ratio
        if new_number < 2:
            break
        unit, number = new_unit, new_number
    shown_num = int(number)
    return '{} {}'.format(shown_num, unit + ('' if shown_num == 1 else 's'))
