import copy


def _set_defaults_temporal(config_in):
    """Return modified config when no temporal args are provided.

    If 'median' is true use "--all" otherwise set "--latest=1"

    """
    config = copy.deepcopy(config_in)
    temporal_args = ('dayofyear', 'month', 'day',
                     'year', 'latest', 'date_range')
    if not config['all']:
        has_temporal_args = any((arg in config) for arg in temporal_args)
        if not has_temporal_args:
            if config['median']:
                config['all'] = True
            else:
                config['latest'] = 1

    return config