A small Flask web app that calculates your exact age from a birth date — down to the day — plus total days/weeks lived and a countdown to your next birthday.
- Exact age in years, months, and days
- Total days and total weeks lived
- Days remaining until your next birthday
- Correctly handles edge cases: leap-year (Feb 29) birthdays, month-end dates (e.g. Jan 31), and short months
- Rejects invalid or future dates with a clear error message
- Backend: Python, Flask
- Frontend: HTML, plain CSS (server-rendered via Jinja2)
git clone https://github.com/NEKOZAM-I/age-calculator.git
cd age-calculatorpython3 -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activatepip install -r requirements.txtpython app.pyOpen http://127.0.0.1:5000 in your browser.
age-calculator/
├── app.py # Flask routes + age calculation logic
├── requirements.txt
├── templates/
│ └── index.html # Form + result page
├── static/
│ └── style.css
├── LICENSE
└── README.md
Naive date subtraction (just subtracting year/month/day fields) breaks on
edge cases — for example, comparing a January 31st birthday against a
28-day February. This app instead walks forward from the birth date one
year at a time, then one month at a time (clamping to the last valid day
of shorter months), and only takes the remaining day difference at the
end. This matches how calendar libraries like dateutil.relativedelta
handle the same problem, without adding a dependency.
- Show age in alternate units (total hours, total minutes)
- Zodiac sign / day-of-week-born fun facts
- Compare ages between two people
MIT — see LICENSE.