def quantized(td):
    """Return a string based on the supplied datetime.timedelta 'td'.

    Generate descriptions that fall nicely into buckets so that timedeltas
    that happened at 'roughly' the same time will have the same description.

    The timedelta will be described using the largest 'human' unit that it has
    more than one of; e.g. '1 hour, 20 minutes, 6 seconds' becomes '1 hour'.

    Usage examples:
        quantize 1 hour, 20 minutes, 6 seconds
        >>> import datetime; quantized(datetime.timedelta(seconds=60*80+6))
        '1 hour'

        quantize 2.1 hours
        >>> import datetime; quantized(datetime.timedelta(seconds=60*60*2.1))
        '2 hours'

        quantize 1 day, 60 seconds
        >>> import datetime; quantized(datetime.timedelta(days=1, seconds=60))
        '1 day'

        quantize 20 seconds
        >>> import datetime; quantized(datetime.timedelta(seconds=20))
        '20 seconds'

        quantize 0 seconds
        >>> import datetime; quantized(datetime.timedelta(seconds=0))
        'no time'

    :td: a datetime.timedelta
    :returns: a string describing the supplied 'td'

    """
    buckets = [
        ("year", 60 * 60 * 24 * 365),
        ("month", 60 * 60 * 24 * 7 * 4),
        ("week", 60 * 60 * 24 * 7),
        ("day", 60 * 60 * 24),
        ("hour", 60 * 60),
        ("minute", 60),
        ("second", 1),
    ]

    remainder = td.total_seconds()
    for (unit_name, seconds_per_unit) in buckets:
        units = int(remainder // seconds_per_unit)
        if units >= 1:
            if units > 1:
                unit_name += 's'
            return str(units) + " " + unit_name

    return "no time"