def families(repository): familyTable = PrettyTable() familyTable.field_names = [ "ID", "Married", "Divorced", "Husband ID", "Husband Name", "Wife ID", "Wife Name", "Children" ] for family in repository.getFamilies(): familyTable.add_row([ family.getFamId(), formatDate(family.getMarriageDate()), formatDate(family.getDivorceDate()), family.getHusbandId(), repository.getPerson(family.getHusbandId()).getName(), family.getWifeId(), repository.getPerson(family.getWifeId()).getName(), family.getChildrenIds() ]) print("Families:") print(familyTable)
def upcomingAnniversaries(repository): anniversaryTable = PrettyTable() anniversaryTable.field_names = [ "ID", "Anniversary", "Husband ID", "Husband Name", "Wife ID", "Wife Name" ] for family in repository.getFamilies(): marriageDay = formatDate(family.getMarriageDate())[4:] currentYear = str(datetime.now().year) anniversary = datetime.strptime(currentYear + marriageDay, "%Y-%m-%d").date() now = datetime.now().date() thirtyDaysAgo = now - timedelta(30) if thirtyDaysAgo <= anniversary <= now: anniversaryTable.add_row([ family.getFamId(), formatDate(family.getMarriageDate())[5:], family.getHusbandId(), repository.getPerson(family.getHusbandId()).getName(), family.getWifeId(), repository.getPerson(family.getWifeId()).getName() ]) print("US39: Recent Anniversaries:") print(anniversaryTable)
def datesAreValid(dates): for date in dates: formatDate(date)