Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🎂 Age Calculator

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.

Features

  • 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

Tech Stack

  • Backend: Python, Flask
  • Frontend: HTML, plain CSS (server-rendered via Jinja2)

Getting Started

1. Clone and enter the project

git clone https://github.com/NEKOZAM-I/age-calculator.git
cd age-calculator

2. Create a virtual environment (recommended)

python3 -m venv venv
source venv/bin/activate   # Windows: venv\Scripts\activate

3. Install dependencies

pip install -r requirements.txt

4. Run the app

python app.py

Open http://127.0.0.1:5000 in your browser.

Project Structure

age-calculator/
├── app.py                # Flask routes + age calculation logic
├── requirements.txt
├── templates/
│   └── index.html        # Form + result page
├── static/
│   └── style.css
├── LICENSE
└── README.md

How the Math Works

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.

Possible Improvements

  • Show age in alternate units (total hours, total minutes)
  • Zodiac sign / day-of-week-born fun facts
  • Compare ages between two people

License

MIT — see LICENSE.

About

Age calculator for month, day and year

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages