-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUS08_birth_before_marriage_of_parents.py
42 lines (36 loc) · 1.33 KB
/
US08_birth_before_marriage_of_parents.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from print_data import *
def US08_birth_before_marriage_of_parents():
userStoryName('US08')
diff = False
family = get_family()
for doc in family:
if (("CHILDREN" in doc) and ("HUSBAND" in doc) and ("WIFE" in doc) and ("marriage" in doc)) and doc[
'marriage'] is not None:
for child in doc["CHILDREN"]:
birthday = get_birth_date(child)
marriage_date = datetime.date(datetime.strptime(doc["marriage"],"%Y-%m-%d %H:%M:%S"))
if("divorce" in doc):
marriage_date = datetime.date(datetime.strptime(doc["divorce"],"%Y-%m-%d %H:%M:%S"))
diff = valid_difference_marriage_and_child(marriage_date,birthday)
else:
diff = valid_difference_marriage_and_child(marriage_date,birthday)
if(diff == True):
output('\t'+doc["FAMID"] +'\t\t%-10s'+ str(birthday) + '\t\t%-10s' % str(marriage_date))
def get_birth_date(individual):
indi = get_person_details(individual)
for doc in indi:
if "birthday" in doc:
birth_date = datetime.date(datetime.strptime(doc["birthday"],"%Y-%m-%d %H:%M:%S") )
else:
birth_date = ""
return birth_date
def valid_difference_marriage_and_child(marriage_date, child_birthDate):
delta = child_birthDate - marriage_date
if ((int(delta.days/30.4)) < -9):
return True
else:
return False
def main():
US08_birth_before_marriage_of_parents()
if __name__ == "__main__":
main()