dttools
A simple Python library for common date and time manipulations.
Installation
pip install dttools
Requires Python 3.10+. Uses the standard library's zoneinfo for timezones
(no pytz). On Windows, tzdata is pulled in automatically.
Usage
Adding (or subtracting) business days
from dttools import add_business_days
from datetime import datetime, date
start_date = datetime(2023, 11, 10)
add_business_days(start_date, 5) # 5 business days forward, skipping weekends
add_business_days(start_date, -3) # 3 business days backward
# Optionally skip holidays too
add_business_days(start_date, 5, holidays={date(2023, 11, 23)})
Counting business days between two dates
from dttools import days_between_in_business_days
from datetime import datetime
days_between_in_business_days(datetime(2023, 11, 1), datetime(2023, 11, 10))
# Counts weekdays from start (inclusive) up to end (exclusive).
Checking business days and weekends
from dttools import is_business_day, is_weekend
from datetime import date
is_business_day(date(2023, 11, 10)) # True (Friday)
is_business_day(date(2023, 11, 11)) # False (Saturday)
is_weekend(date(2023, 11, 11)) # True
Human-readable relative dates
from dttools import format_relative_date
from datetime import datetime, timedelta
now = datetime.now()
format_relative_date(now - timedelta(minutes=30)) # "30 minutes ago"
format_relative_date(now - timedelta(hours=2)) # "2 hours ago"
format_relative_date(now - timedelta(days=3)) # "3 days ago"
format_relative_date(now + timedelta(days=1)) # "Tomorrow"
Converting to a specific timezone
from dttools import to_timezone
from datetime import datetime, timezone
utc_now = datetime.now(timezone.utc)
to_timezone(utc_now, "America/New_York")
Naive datetimes are treated as UTC.
License
MIT - see LICENSE.
Metadata
Release files for dttools 1.0.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 | Provenance | Actions |
|---|---|---|---|---|
| dttools-1.0.0.tar.gz | 3.4 MB | Without provenance | Details for dttools-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dttools-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for dttools-1.0.0-py3-none-any.whl |
Total release size: 7.6 MB
Release files / dttools-1.0.0.tar.gz
| Download URL | dttools-1.0.0.tar.gz |
|---|---|
| Size | 3.4 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ffc2ce3bbba40f0128423bfee7763dfdd5f6f345148d7b2451657047db0902c8
|
|
BLAKE2b-256 checksum How to use checksums |
e450bfef20a7fda22e70d99494e87834282e456ad50153a7627f6b0627f57728
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.5
|
Release files / dttools-1.0.0-py3-none-any.whl
| Download URL | dttools-1.0.0-py3-none-any.whl |
|---|---|
| Size | 4.1 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d8ae58caaeb76c30e660673b7c1534ce7f156d10b24f8d2f090dd56b920714f9
|
|
BLAKE2b-256 checksum How to use checksums |
fc48061617edca9a91ebc4d5ad268e9ddcd85df4f581522791152008f5cc1b31
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.5
|
Security for dttools 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.