def recent_date(last_seen=False, **kwargs):
    """Select a recent date range for a location selector.

    :keyword resolution: One keyword time resolution specifier, e.g. ``hours``
        or ``days``.
    :type resolution: int
    :keyword last_seen: Select only devices last seen in this location. Defaults
        to False.

    >>> recent_date(months=6)
    {'recent': {'months': 6}}
    >>> recent_date(weeks=3, last_seen=True)
    {'last_seen': True, 'recent': {'weeks': 3}}
    """
    if not len(kwargs) == 1:
        raise ValueError('Must specificy a single date resolution')
    resolution = kwargs.keys()[0]
    value = kwargs.values()[0]
    if resolution not in 'minuteshoursdaysweeksmonthsyears':
        raise ValueError('Invalid date resolution: %s' % resolution)
    payload = {'recent': {resolution: value}}
    if last_seen:
        payload['last_seen'] = True
    return payload
