Spaces:
Paused
Paused
Davide Fiocco
commited on
Commit
·
d8d8f1a
1
Parent(s):
39b564c
Revise age calculation
Browse files
utils.py
CHANGED
@@ -27,6 +27,7 @@ def get_answer(input, context, engine, threshold=0.5):
|
|
27 |
def get_context():
|
28 |
|
29 |
BIRTHYEAR = 1952
|
|
|
30 |
OTHERBIRTHYEAR = 1984
|
31 |
now = datetime.datetime.now()
|
32 |
|
@@ -36,7 +37,10 @@ def get_context():
|
|
36 |
.replace("[YEAR]", str(now.year))
|
37 |
.replace("[TODAY]", f"{datetime.datetime.now():%d-%m-%Y}")
|
38 |
.replace("[BIRTHYEAR]", str(BIRTHYEAR))
|
39 |
-
.replace(
|
|
|
|
|
|
|
40 |
.replace("[OTHERAGE]", str(now.year - OTHERBIRTHYEAR))
|
41 |
)
|
42 |
|
|
|
27 |
def get_context():
|
28 |
|
29 |
BIRTHYEAR = 1952
|
30 |
+
BIRTHMONTH = 5
|
31 |
OTHERBIRTHYEAR = 1984
|
32 |
now = datetime.datetime.now()
|
33 |
|
|
|
37 |
.replace("[YEAR]", str(now.year))
|
38 |
.replace("[TODAY]", f"{datetime.datetime.now():%d-%m-%Y}")
|
39 |
.replace("[BIRTHYEAR]", str(BIRTHYEAR))
|
40 |
+
.replace(
|
41 |
+
"[AGE]",
|
42 |
+
str((now - datetime.datetime(BIRTHYEAR, BIRTHMONTH, 1)).days // 365),
|
43 |
+
)
|
44 |
.replace("[OTHERAGE]", str(now.year - OTHERBIRTHYEAR))
|
45 |
)
|
46 |
|