def list_recent_births(parser, db): tables = [] recents = [] today = date.today() for person in parser.individuals.values(): if person.birth is not None: if (DateHelpers.dates_within(today, person.birth, 30, "days")): recents.append(person) tables.append( TableHelpers.individuals2table(recents, "US35: Recent Births")) return tables
def list_orphans(parser): '''List all children younger than 18 with both parents deceased''' tables = [] orphans = [] for id in parser.families: family = parser.families[id] mother = parser.individuals[family.wife_id] father = parser.individuals[family.husband_id] if mother.death and father.death: for child_id in family.child_ids: child = parser.individuals[child_id] if DateHelpers.calculate_age(child.birth, None) < 18: orphans.append(child) pt = TableHelpers.individuals2table(orphans, "US33: List Orphans") tables.append(pt) return tables
def upcoming_birthdays(parser): tables = [] today = date.today() upcoming_people = [] for individual in parser.individuals.values(): updated = date(today.year, individual.birth.month, individual.birth.day) # If we've passed the date, we check the next year if updated < today: updated = date(today.year + 1, individual.birth.month, individual.birth.day) if DateHelpers.date_diff(updated, today, "days") <= 30: upcoming_people.append(individual) tables.append( TableHelpers.individuals2table(upcoming_people, "US38: Upcoming Birthdays")) return tables