date-difference-calculator
A lightweight Python library that calculates the absolute difference in days between two Python date objects.
Overview
date-difference-calculator is a zero-dependency Python library designed to calculate the absolute integer difference in calendar days between two standard library datetime.date instances. It guarantees non-negative output regardless of the argument order.
Requirements
- Python
>= 3.12
Installation
Install using pip:
pip install date-difference-calculator
Or using uv:
uv add date-difference-calculator
Usage Example
from datetime import date
from date_difference_calculator import calculate_date_difference
start_date = date(2026, 8, 11)
end_date = date(2026, 8, 20)
# Forward-date calculation
diff = calculate_date_difference(start_date, end_date)
print(diff) # Output: 9
# Reversed-date calculation (order does not affect output; result is non-negative)
diff_reverse = calculate_date_difference(end_date, start_date)
print(diff_reverse) # Output: 9
# Same-date calculation
diff_same = calculate_date_difference(start_date, start_date)
print(diff_same) # Output: 0
API Reference
calculate_date_difference(start_date, end_date)
Calculates the absolute difference in days between two datetime.date objects.
Parameters:
start_date(datetime.date): The first date.end_date(datetime.date): The second date.
Returns:
int: The non-negative number of calendar days betweenstart_dateandend_date.
Current Scope & Limitations
This initial release (v0.1.0) strictly supports calendar-day calculation for date objects:
- Type Requirement: Operates exclusively on Python
datetime.dateobjects. - Unit of Measurement: Calculates absolute difference in full calendar days (accounting for leap years and month/year boundaries).
- No Time or Timezone Support: Does not accept
datetime.datetimeobjects, time components, or timezones. - No Calendar Customization: Does not calculate business days, workdays, or holiday-adjusted schedules.
Development & Testing
To run the project test suite during development:
# Run tests using pytest
pytest
# Or run tests via uv
uv run pytest
License
Distributed under the terms of the MIT License.
Metadata
Release files for date-difference-calculator 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| date_difference_calculator-0.1.0.tar.gz | 1.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| date_difference_calculator-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 4.6 kB
Release files / date_difference_calculator-0.1.0.tar.gz
| Download URL | date_difference_calculator-0.1.0.tar.gz |
|---|---|
| Size | 1.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e34a79d3b1d5cb6ecae43fd9ce9b671170c8b59e628aed306192238cc63b9b90
|
|
BLAKE2b-256 checksum How to use checksums |
c4acd48b79b3d69c8bdd35b2fbc484624b9aa50fd304a82cf577d976b4f5056f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.8 {"installer":{"name":"uv","version":"0.12.8","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}
|
Release files / date_difference_calculator-0.1.0-py3-none-any.whl
| Download URL | date_difference_calculator-0.1.0-py3-none-any.whl |
|---|---|
| Size | 2.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fc00e0bdc42b3840607dc18f42dbf5fd0a6cfc9dc7f73747caede4e4a55075f5
|
|
BLAKE2b-256 checksum How to use checksums |
be49429a1ef6f1a4ca1ae1208d733f73a23f2e0d486dfecb0c92b81e1ff802d3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.8 {"installer":{"name":"uv","version":"0.12.8","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}
|