Skip to main content

tDt — universal time delta toolkit

Project description

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

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

time_delta_t-0.1.3.tar.gz (13.8 kB view details)

Uploaded Source

Built Distribution

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

time_delta_t-0.1.3-py3-none-any.whl (11.6 kB view details)

Uploaded Python 3

File details

Details for the file time_delta_t-0.1.3.tar.gz.

File metadata

  • Download URL: time_delta_t-0.1.3.tar.gz
  • Upload date:
  • Size: 13.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for time_delta_t-0.1.3.tar.gz
Algorithm Hash digest
SHA256 14da27bfdfaef3666bd2d3aef1154434615790ec78f5c472df341f8ee01e2670
MD5 24e100e5391777b33af011bef946ce79
BLAKE2b-256 edbea593b47c1e986d012919c894ef902eaf0a8135fee8100334ca8464fddbdc

See more details on using hashes here.

File details

Details for the file time_delta_t-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: time_delta_t-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 11.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for time_delta_t-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 30f5f03e2cbf0d26e19faf080a8d83d576b1fc69127723631e79e8bb9b5c17c5
MD5 2f918ba68233899ab05a88129c4a3420
BLAKE2b-256 1b14512b466dc94517c33aac88f867e242324a460e1dca59fa728f2ba9498645

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