Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,18 +1,19 @@
|
|
1 |
import streamlit as st
|
2 |
from datetime import date
|
|
|
3 |
|
4 |
# Configure the page
|
5 |
st.set_page_config(page_title="Age Calculator", layout="centered")
|
6 |
|
7 |
# Title and intro
|
8 |
st.title("π Age Calculator")
|
9 |
-
st.subheader("
|
10 |
|
11 |
-
#
|
12 |
min_dob = date(1950, 1, 1)
|
13 |
max_dob = date.today()
|
14 |
|
15 |
-
# Date input with
|
16 |
dob = st.date_input("π
Select your Date of Birth", min_value=min_dob, max_value=max_dob, value=date(2000, 1, 1))
|
17 |
|
18 |
# Buttons
|
@@ -27,8 +28,8 @@ with col3:
|
|
27 |
# Logic
|
28 |
if calculate:
|
29 |
today = date.today()
|
30 |
-
|
31 |
-
st.success(f"π You are {
|
32 |
|
33 |
if clear:
|
34 |
st.experimental_rerun()
|
|
|
1 |
import streamlit as st
|
2 |
from datetime import date
|
3 |
+
from dateutil.relativedelta import relativedelta
|
4 |
|
5 |
# Configure the page
|
6 |
st.set_page_config(page_title="Age Calculator", layout="centered")
|
7 |
|
8 |
# Title and intro
|
9 |
st.title("π Age Calculator")
|
10 |
+
st.subheader("Find your exact age in Years, Months, and Days")
|
11 |
|
12 |
+
# Min and max date
|
13 |
min_dob = date(1950, 1, 1)
|
14 |
max_dob = date.today()
|
15 |
|
16 |
+
# Date input with limits
|
17 |
dob = st.date_input("π
Select your Date of Birth", min_value=min_dob, max_value=max_dob, value=date(2000, 1, 1))
|
18 |
|
19 |
# Buttons
|
|
|
28 |
# Logic
|
29 |
if calculate:
|
30 |
today = date.today()
|
31 |
+
diff = relativedelta(today, dob)
|
32 |
+
st.success(f"π You are {diff.years} years, {diff.months} months, and {diff.days} days old!")
|
33 |
|
34 |
if clear:
|
35 |
st.experimental_rerun()
|