def in_custom_unit(td, seconds_per_unit, unit_name):
    """Return a string describing the number of whole 'unit_name' in 'td'.

    'seconds_per_unit' is used as the divisor to determine how many whole units
    are present in 'td'.

    If the number of units is other than 1, an 's' is appended to the name of
    the unit to make it plural.

    Usage examples:

        24 hours in days
        >>> import datetime; in_named_unit(
        ...     datetime.timedelta(seconds=60*60*24), 'day')
        '1 day'

        50 hours in days
        >>> import datetime; in_named_unit(
        ...     datetime.timedelta(seconds=60*60*50), 'day')
        '2 days'

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

    """
    seconds = td.total_seconds()
    units = int(seconds // seconds_per_unit)
    if units != 1:
        unit_name += 's'
    return ' '.join([str(units), unit_name])