tDt
tDt (time delta toolkit) — a Python library for counting elapsed time in flexible, exact units.
Think of it as a universal stopwatch: from milliseconds to millennia, tDt gives you consistent tick counts without worrying about calendars or floating-point drift.
✨ Why tDt?
Time in most software is messy:
- Datetime APIs give you inconsistent results across months, leap years, daylight savings.
- Floating-point math introduces rounding errors.
- Simulations need exact, repeatable tick counts.
tDt fixes this with:
- Deterministic results: same input, same output — no surprises.
- Raw totals in all units: years, weeks, days, seconds, down to nanoseconds.
- Human-readable breakdowns: quickly see years + months + days.
- Simple API: two functions cover 95% of use cases.
🚀 Installation
pip install time-delta-t
🛠 Usage
Count ticks between two dates
from datetime import datetime
from tdt import count_ticks
start = datetime(2000, 1, 1)
end = datetime(2020, 1, 1)
print(count_ticks(start, end, "days")) # → 7305
print(count_ticks(start, end, "weeks")) # → 1043
print(count_ticks(start, end, "seconds"))# → 631152000
Get a full breakdown
from datetime import datetime
from tdt import breakdown_all
start = datetime(2000, 1, 1)
end = datetime(2002, 2, 15)
print(breakdown_all(start, end))
Output:
{
"millennia": 0,
"centuries": 0,
"decades": 0,
"years": 2.12,
"months": 25.5,
"weeks": 111,
"days": 780,
"hours": 18720,
"minutes": 1123200,
"seconds": 67392000,
"milliseconds": 67392000000,
"microseconds": 67392000000000,
"nanoseconds": 67392000000000000
}
Pretty breakdown (human-friendly)
from datetime import datetime
from tdt import pretty_breakdown
start = datetime(2000, 1, 1)
end = datetime(2002, 2, 15)
print(pretty_breakdown(start, end))
# → "2 years, 1 month, 14 days"
🔍 Use Cases
-
Simulation & modeling
- Drive tick-based engines with exact elapsed cycles.
- e.g., count pump rotations, wire oscillations, planetary orbits.
-
Robotics & IoT
- Synchronize devices using tick counts instead of fuzzy floating time.
-
Data processing
- Express spans in whatever unit makes sense (seconds, days, months).
-
Frontend/UI
- Show users “time since install” or “lifespan remaining” in clean units.
📖 Roadmap
- Add support for custom tick rates (e.g. 3600 ticks/hour = RPM).
- Integrations with physics/material models.
- Optional Rust/C++ backend for high-performance batch use.
📝 License
Apache 2.0 © Dr. Ippy
Metadata
Release files for time-delta-t 0.1.3
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 |
|---|---|---|---|---|
| time_delta_t-0.1.3.tar.gz | 13.8 kB | Without provenance | Details for time_delta_t-0.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| time_delta_t-0.1.3-py3-none-any.whl | Python 3 | none | any | Details for time_delta_t-0.1.3-py3-none-any.whl |
Total release size: 25.5 kB
Release files / time_delta_t-0.1.3.tar.gz
| Download URL | time_delta_t-0.1.3.tar.gz |
|---|---|
| Size | 13.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
14da27bfdfaef3666bd2d3aef1154434615790ec78f5c472df341f8ee01e2670
|
|
BLAKE2b-256 checksum How to use checksums |
edbea593b47c1e986d012919c894ef902eaf0a8135fee8100334ca8464fddbdc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.3
|
Release files / time_delta_t-0.1.3-py3-none-any.whl
| Download URL | time_delta_t-0.1.3-py3-none-any.whl |
|---|---|
| Size | 11.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
30f5f03e2cbf0d26e19faf080a8d83d576b1fc69127723631e79e8bb9b5c17c5
|
|
BLAKE2b-256 checksum How to use checksums |
1b14512b466dc94517c33aac88f867e242324a460e1dca59fa728f2ba9498645
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.3
|
Security for time-delta-t 0.1.3
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.