Skip to main content

No project description provided

Project description

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! :)

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

readabledelta2-0.0.2.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

readabledelta2-0.0.2-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file readabledelta2-0.0.2.tar.gz.

File metadata

  • Download URL: readabledelta2-0.0.2.tar.gz
  • Upload date:
  • Size: 9.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.4

File hashes

Hashes for readabledelta2-0.0.2.tar.gz
Algorithm Hash digest
SHA256 3d28949d0b85acbcbd2805b3037b11c10eaeb0a9db60cf9a1058a8e27c374ebe
MD5 d03a7c40bf4c27000a4288883385d1a9
BLAKE2b-256 5c2e6831d2c097dfdeeb5c95c6b5d92bc45a13ec215c608e3a1199bdc837c219

See more details on using hashes here.

File details

Details for the file readabledelta2-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for readabledelta2-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e2f762b4a41484a24723930976973bb37706c26f17686d974183241d4140250d
MD5 9a2a1d91426c64370e42f2e121ae798f
BLAKE2b-256 bb4271752b4db192b8a6ae2db472e5757f4f4983dc2d6e174559e8b822823925

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page