Skip to main content

A tiny CLI that calculates an age and next birthday from a birth date.

Project description

pyagecalc

A small command-line tool that calculates someone's age and tells you when their next birthday falls.

$ agecalc 1994 07 01
30 years old today 2025-05-27
Will turn 31 on next birthday 2025-07-01

Install

The package is published as pyagecalc on PyPI and exposes the agecalc command.

Using uv (recommended):

uv tool install pyagecalc

Run without installing:

uvx --from pyagecalc agecalc 1994 07 01

Or with pipx:

pipx install pyagecalc

You can also run the module form once the package is on your PYTHONPATH:

python -m agecalc 1994 07 01

CLI reference

agecalc [-h | --help] YEAR [MONTH] [DAY]
Argument Required Format Default Description
YEAR yes YYYY or YY Birth year. A 2-digit year that would otherwise fall in the future is interpreted as 19YY, not 20YY.
MONTH no MM 01 Birth month.
DAY no DD 01 Birth day.
Option Description
-h, --help Show usage and exit (0).

The CLI prints today's age and the date of the next upcoming birthday. If today is the birthday, it prints Turned N today! in place of the next-birthday line. Future birth dates print N years in the future. People born on 29 February have their non-leap-year birthdays observed on 28 February.

Invalid input (a year that is not 2 or 4 digits, a non-numeric month or day, or a date that does not exist on the calendar) exits with status 2 and a click-formatted error message on standard error.

Examples

# Full date with a 4-digit year
agecalc 1994 07 01

# Year only — month and day default to 01
agecalc 1994

# 2-digit year (auto-expanded against the current year)
agecalc 94 07 01      # → 1994-07-01
agecalc 22 07 01      # → 2022-07-01

# A future birth date
agecalc 2050 01 01    # → 24 years in the future

Library use

The package ships type information (PEP 561 py.typed), so any importer gets full type-checking out of the box:

from whenever import Date

from agecalc import calculate_age, calculate_next_birthday, expand_year

calculate_age(Date(1994, 7, 1))
calculate_next_birthday(Date(1994, 7, 1))
expand_year(94)

All three functions are pure and read "today" from the system timezone via whenever.Date.today_in_system_tz(). See the docstrings (NumPy style) for the full signature and behaviour, including the 29 February fallback.

Dependencies

Runtime: click for the CLI and whenever for the date arithmetic. Nothing else.

Development

The project is managed with uv and uses a src/ layout.

# Clone and set up
git clone https://github.com/LunaPurpleSunshine/Age-Calculator.git
cd Age-Calculator
uv sync --all-groups

# Run the CLI from your checkout
uv run agecalc 1994 07 01

# Tests, lint, type-check, build
uv run pytest --cov=agecalc
uv run ruff check .
uv run ruff format --check .
uv run mypy
uv build

Pre-commit hooks

The repo ships a .pre-commit-config.yaml that runs ruff (lint + format) and a handful of file-hygiene hooks on commit. Use prek (a fast, drop-in replacement for pre-commit):

uv tool install prek
prek install            # install the git hook in this clone
prek run --all-files    # run all hooks against the whole repo

CI runs the same checks across Python 3.12, 3.13, and 3.14 on every push and pull request, plus a uv build + twine check job to verify the built distribution.

Licence

Released under the MIT licence — see LICENCE.txt for the full text.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyagecalc-1.0.0.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyagecalc-1.0.0-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file pyagecalc-1.0.0.tar.gz.

File metadata

  • Download URL: pyagecalc-1.0.0.tar.gz
  • Upload date:
  • Size: 10.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.17 {"installer":{"name":"uv","version":"0.11.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pyagecalc-1.0.0.tar.gz
Algorithm Hash digest
SHA256 0a6485eccb4f3d425b477a54ee6336e8379aec71fef61cce7370e5ba5ae6d778
MD5 4f096a177dbc889ec546030a5aa41295
BLAKE2b-256 83e8a5dd2b8a4de388fc87897216e2db16517617c42cbe9f792807a0a63edcc1

See more details on using hashes here.

File details

Details for the file pyagecalc-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: pyagecalc-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.17 {"installer":{"name":"uv","version":"0.11.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pyagecalc-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9484671cfb7752181659e159d9e345bf3b10c1319ca2d169ee07875ac3099940
MD5 582d493c7ca90f69be7f712a421e9fb1
BLAKE2b-256 24d066e84828635ac8a53d327087b4e038f2332a7a758883745d01fdf7079715

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page