Skip to main content

Print a datetime's distance from now

Project description

Relative To Now

Convert date/time into a string relative to now.

Python Version Codecov Status Codacy Status Pypi Download Downloads

💾 Install

python -m pip install relative-to-now

# or

poetry add relative-to-now

✨ How to Use

Possible input types:

  • time.time()
  • datetime.date.today()
  • datetime.datetime.now()

Optional inputs:

  • no_errors (Defaults to False, set to True to return value when there is an error instead of raising)

Output:

Examples:

import datetime
from RelativeToNow import relative_to_now

print(relative_to_now(datetime.datetime.now() + datetime.timedelta(days=1)))
>>> 1 day from now

Precision for datetime.date is days.

import datetime
from RelativeToNow import relative_to_now

print(relative_to_now(datetime.date.today() - datetime.timedelta(days=2)))
>>> 2 days ago
import time
from RelativeToNow import relative_to_now

print(relative_to_now(time.time()))
>>> just now

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

relative_to_now-1.1.0.tar.gz (15.1 kB view details)

Uploaded Source

Built Distribution

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

relative_to_now-1.1.0-py3-none-any.whl (15.2 kB view details)

Uploaded Python 3

File details

Details for the file relative_to_now-1.1.0.tar.gz.

File metadata

  • Download URL: relative_to_now-1.1.0.tar.gz
  • Upload date:
  • Size: 15.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.11.0 Linux/5.15.0-1030-azure

File hashes

Hashes for relative_to_now-1.1.0.tar.gz
Algorithm Hash digest
SHA256 c3c4a8963a3b823c3d8415a96f75226d617ef378c6d5e6c94cddb9eccdf8820a
MD5 2aaabe88b59d03a7a7e780b881e17d82
BLAKE2b-256 fdfb1790f745b5d01d52d4d1864e784ddebf9b25bfb8fd3aebc1261b83f4a793

See more details on using hashes here.

File details

Details for the file relative_to_now-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: relative_to_now-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 15.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.11.0 Linux/5.15.0-1030-azure

File hashes

Hashes for relative_to_now-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 88bd05d363bdd2007ec96edf0e3a8dc5cbbb248ec5d42e7322bc888252d7f6e1
MD5 40dc4df18c94a45345b47cb65e5c1250
BLAKE2b-256 02216a2a467c2ef6c3c2e259a9e02cfffb695ac1163659b8ba0e69bb8a9c15ec

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