from datetime import datetime


def update_reader_settings(iteration, reader_settings):
    """Auxiliar function, returns the settings passed to the reader
    with updated dates. Updated dates are shifted always by the same
    interval defined by the difference between NewestNewsDate and
    the OldestNewsDate.

    Args:

        iteration (int): number of current iteration.
        reader_settings (dict): contains reader settings to be updated.
    """
    if iteration > 0:
        newest_news_date = datetime.strptime(
            reader_settings["NewestNewsDate"], "%Y-%m-%d")
        oldest_news_date = datetime.strptime(
            reader_settings["OldestNewsDate"], "%Y-%m-%d")
        delta = newest_news_date - oldest_news_date

        reader_settings["OldestNewsDate"] = str(
            (oldest_news_date - delta).date())
        reader_settings["NewestNewsDate"] = str(
            (newest_news_date - delta).date())

    return reader_settings