Skip to main content

Readable Timedelta (mark2)

Build Status Build Status

Supported Versions Checked with mypy Code style: black Imports: isort Ruff

Installation

pip install readabledelta2

Usage examples

from_timedelta creates a more human-friendly printable version of timedelta.

>>> delta = timedelta(weeks=53, hours=1, minutes=1)
>>> f"Update was {delta} ago"
'Update was 371 days, 1:01:00 ago'
>>> f"Update was {from_timedelta(delta)} ago"
'Update was 1 year, 6 days, 1 hour and 1 minute ago'

For negative timedeltas, the default representation is more machine-friendly than human-friendly: "an hour and five minutes" is easier for people to understand than the weird but technically-correct "negative one day plus 22 hours and 55 minutes"

>>> lunchtime = datetime(year=2015, month=5, day=27, hour=12)
>>> right_now = datetime(year=2015, month=5, day=27, hour=13, minute=5)
>>> f"{lunchtime - right_now}"
'-1 day, 22:55:00'
>>> f"{from_timedelta(lunchtime - right_now)}"
'-1 hour and 5 minutes'

Contributing

You want to contribute? Great! Here are the things you should do before submitting your PR:

  1. Fork the repo and git clone your fork.
  2. dev install the project package:
    1. pip install -e .[dev]
    2. Optional (poetry users):
      1. poetry install --extras dev
  3. Run tox to perform tests frequently.
  4. Create pull-request from your branch.

That's it! :)

Metadata

Release files for readabledelta2 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for readabledelta2 0.0.2
File Size Uploaded
readabledelta2-0.0.2.tar.gz 9.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for readabledelta2 0.0.2
File Interpreter ABI Platform
readabledelta2-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 17.0 kB

Release files / readabledelta2-0.0.2.tar.gz

Download URL readabledelta2-0.0.2.tar.gz
Size 9.5 kB
Tags Source
SHA-256 checksum
How to use checksums
3d28949d0b85acbcbd2805b3037b11c10eaeb0a9db60cf9a1058a8e27c374ebe
BLAKE2b-256 checksum
How to use checksums
5c2e6831d2c097dfdeeb5c95c6b5d92bc45a13ec215c608e3a1199bdc837c219
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.12.4

Release files / readabledelta2-0.0.2-py3-none-any.whl

Download URL readabledelta2-0.0.2-py3-none-any.whl
Size 7.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e2f762b4a41484a24723930976973bb37706c26f17686d974183241d4140250d
BLAKE2b-256 checksum
How to use checksums
bb4271752b4db192b8a6ae2db472e5757f4f4983dc2d6e174559e8b822823925
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.12.4

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page