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 hashes)

Uploaded Source

Built Distribution

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

Uploaded Python 3

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