コード例 #1
0
def world_population_rank_by_age(request, dob, sex, country, age):
    """ Calculates the world population rank of a person with the given date of birth, sex and country of origin on a certain date as expressed by the person's age.<p>The world population rank is defined as the position of someone's birthday among the group of living people of the same sex and country of origin, ordered by date of birth increasing. The first person born is assigned rank #1.<p>
        Please see <a href="/">the full API browser</a> for more information.
    """
    rank = worldPopulationRankByDate(sex, country, dob, dob + age)
    return Response({
        "rank": rank,
        'dob': dob,
        'sex': sex,
        'country': country,
        'age': offset_to_str(age)
    })
コード例 #2
0
def world_population_rank_in_future(request, dob, sex, country, offset):
    """ Calculates the world population rank of a person with the given date of birth, sex and country of origin on a certain date as expressed by an offset towards the future from today.<p>The world population rank is defined as the position of someone's birthday among the group of living people of the same sex and country of origin, ordered by date of birth increasing. The first person born is assigned rank #1.<p>Today's date is always based on the current time in the timezone UTC.<p>
        Please see <a href="/">the full API browser</a> for more information.
    """
    today = datetime.datetime.utcnow().date()
    rank = worldPopulationRankByDate(sex, country, dob, today + offset)
    return Response({
        "rank": rank,
        'dob': dob,
        'sex': sex,
        'country': country,
        'offset': offset_to_str(offset)
    })
コード例 #3
0
def calculate_remaining_life_expectancy(request, sex, country, date, age):
    """ Calculate remaining life expectancy of a person with given sex, country, and age at a given point in time.<p>
        Please see <a href="/">the full API browser</a> for more information.
    """
    remaining_life_expectancy = lifeExpectancyRemaining(
        sex, country, date, age)
    return Response({
        'date': date,
        'sex': sex,
        'country': country,
        'age': offset_to_str(age),
        'remaining_life_expectancy': remaining_life_expectancy
    })
コード例 #4
0
def calculate_remaining_life_expectancy(request, sex, country, date, age):
    """ Calculate remaining life expectancy of a person with given sex, country, and age at a given point in time.<p>
        Please see <a href="/">the full API browser</a> for more information.
    """
    remaining_life_expectancy = lifeExpectancyRemaining(sex, country, date, age)
    return Response({'date': date, 'sex': sex, 'country': country, 'age': offset_to_str(age), 'remaining_life_expectancy': remaining_life_expectancy})
コード例 #5
0
def world_population_rank_in_future(request, dob, sex, country, offset):
    """ Calculates the world population rank of a person with the given date of birth, sex and country of origin on a certain date as expressed by an offset towards the future from today.<p>The world population rank is defined as the position of someone's birthday among the group of living people of the same sex and country of origin, ordered by date of birth increasing. The first person born is assigned rank #1.<p>Today's date is always based on the current time in the timezone UTC.<p>
        Please see <a href="/">the full API browser</a> for more information.
    """
    today = datetime.datetime.utcnow().date()
    rank = worldPopulationRankByDate(sex, country, dob, today + offset)
    return Response({"rank": rank, 'dob': dob, 'sex': sex, 'country': country, 'offset': offset_to_str(offset)})
コード例 #6
0
def world_population_rank_by_age(request, dob, sex, country, age):
    """ Calculates the world population rank of a person with the given date of birth, sex and country of origin on a certain date as expressed by the person's age.<p>The world population rank is defined as the position of someone's birthday among the group of living people of the same sex and country of origin, ordered by date of birth increasing. The first person born is assigned rank #1.<p>
        Please see <a href="/">the full API browser</a> for more information.
    """
    rank = worldPopulationRankByDate(sex, country, dob, dob + age)
    return Response({"rank": rank, 'dob': dob, 'sex': sex, 'country': country, 'age': offset_to_str(age)})
コード例 #7
0
 def __init__(self, invalidValue):
     self.detail = 'The age %s can not be processed, because only calculations up to an age of 100 years are supported' % offset_to_str(invalidValue)