Print a datetime's distance from now
Project description
Relative To Now
Convert date/time into a string relative to now.
💾 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 toFalse
, set toTrue
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
Release history Release notifications | RSS feed
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 hashes)
Built Distribution
Close
Hashes for relative_to_now-1.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 88bd05d363bdd2007ec96edf0e3a8dc5cbbb248ec5d42e7322bc888252d7f6e1 |
|
MD5 | 40dc4df18c94a45345b47cb65e5c1250 |
|
BLAKE2b-256 | 02216a2a467c2ef6c3c2e259a9e02cfffb695ac1163659b8ba0e69bb8a9c15ec |