A tool that calculates how many days have passed between a given start date (e.g., a person's birthday or a company's founding date) and an end date (e.g., today), or determines a specific date based on a start date and a number of elapsed days (e.g., what date it will be on the 10000th day since birth).
Project description
ttDays
A tool that calculates how many days have passed between a given start date (e.g., a person's birthday or a company's founding date) and an end date (e.g., today), or determines a specific date based on a start date and a number of elapsed days (e.g., what date it will be on the 10000th day since birth).
Installation
pip install ttdays
Quick Start
from datetime import date
from ttdays import calculate_days_from_dates, calculate_end_date, calculate_start_date
# Calculate days between dates
start = date(2024, 1, 1)
end = date(2024, 1, 10)
days = calculate_days_from_dates(start, end) # Returns 10
# Calculate end date from start date and days
project_end = calculate_end_date(start, 30) # Returns date(2024, 1, 30)
# Calculate start date from end date and days
deadline = date(2024, 6, 15)
prep_start = calculate_start_date(deadline, 60) # Returns date(2024, 4, 16)
Reference
Functions
calculate_days_from_dates(start_date, end_date, include_start=True) -> int
Calculate days between two dates.
calculate_end_date(start_date, days, include_start=True) -> date
Calculate end date from start date and number of days.
calculate_start_date(end_date, days, include_start=True) -> date
Calculate start date from end date and number of days.
Parameters
include_start(bool): Whether to include the start date in the count (default: True)
Class Usage
from ttdays import DateCalculator
calc = DateCalculator()
days = calc.calculate_days_from_dates(start, end)
Examples
Days Since Birth
from datetime import date
from ttdays import calculate_days_from_dates
birth_date = date(1990, 5, 15)
today = date.today()
days_lived = calculate_days_from_dates(birth_date, today)
print(f"Days lived: {days_lived}")
Project Duration
from ttdays import calculate_end_date, calculate_start_date
# 30-day project
project_start = date(2024, 1, 1)
project_end = calculate_end_date(project_start, 30)
# Work backwards from deadline
deadline = date(2024, 6, 15)
work_start = calculate_start_date(deadline, 45)
Include/Exclude Start Date
start = date(2024, 1, 1)
end = date(2024, 1, 3)
# Include start date (default)
days_with_start = calculate_days_from_dates(start, end, include_start=True) # 3
# Exclude start date
days_without_start = calculate_days_from_dates(start, end, include_start=False) # 2
Changelog
v0.1.0 (2024-01-01)
- Initial release
- Basic date calculation functions
- Pydantic v2 input validation
- Comprehensive test suite
License
MIT License – see LICENSE file for details.
Support
- Documentation: https://ttdays.readthedocs.io/
- Issues: https://github.com/well-living/ttdays/issues
- PyPI: https://pypi.org/project/date-calculator/
Author
@well-living – GitHub
Acknowledgments
- Built with Pydantic for robust data validation
- Inspired by common date calculation needs in business applications
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ttdays-0.1.0.tar.gz.
File metadata
- Download URL: ttdays-0.1.0.tar.gz
- Upload date:
- Size: 16.9 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
edf821e7a44b6adddfc984b8b014bad3b1c43262f9f3cbba5c7e05b01e8e9c59
|
|
| MD5 |
f1719b7bfdc09d71fcd1ed8f688dc08a
|
|
| BLAKE2b-256 |
b65e78d2ea81446014ed12fc6e9cd525386077a9b4d56943cbc84efb4d9e7c31
|
File details
Details for the file ttdays-0.1.0-py3-none-any.whl.
File metadata
- Download URL: ttdays-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
679f865c7eed5b4e9ba68139e08353858c565243d20864d5a7cc25f66bebdc46
|
|
| MD5 |
a9729538721639c9689ecc798d8d91ad
|
|
| BLAKE2b-256 |
f040541a2e3a27f3299f4b018e38c2ee4d6247d576b407f0279a209ea810ad60
|