Convert timestamps to relative time phrases like '3 hours ago'
Project description
philiprehberger-timeago
Convert timestamps to relative time phrases like "3 hours ago".
Installation
pip install philiprehberger-timeago
Usage
from philiprehberger_timeago import timeago, timedelta_human
from datetime import datetime, timedelta, timezone
now = datetime.now(timezone.utc)
timeago(now - timedelta(seconds=30)) # "30 seconds ago"
timeago(now - timedelta(hours=3)) # "3 hours ago"
timeago(now - timedelta(days=1)) # "yesterday"
timeago(now + timedelta(days=7)) # "in 1 week"
# Unix timestamps
timeago(1709913600)
# Duration formatting
timedelta_human(timedelta(hours=3, minutes=25)) # "3 hours, 25 minutes"
API
timeago(dt, now=None)— Relative time phrase from datetime, date, or Unix timestamptimedelta_human(td)— Format a timedelta as readable duration
License
MIT
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file philiprehberger_timeago-0.1.2.tar.gz.
File metadata
- Download URL: philiprehberger_timeago-0.1.2.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
79e1ebfe32f470f2d8cae743a44dace424b42f044e871d60288795991fb0239f
|
|
| MD5 |
ce7773fe7bf958f62085f03a64c1ca59
|
|
| BLAKE2b-256 |
b6529cbff98872e97d29bee4487ceca03b913595233bddc4c09882192991e88b
|
File details
Details for the file philiprehberger_timeago-0.1.2-py3-none-any.whl.
File metadata
- Download URL: philiprehberger_timeago-0.1.2-py3-none-any.whl
- Upload date:
- Size: 4.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9fb662dc697aa49865e21be8e0e1df2e88b875e776045c20c8ca3c7dc488c9f0
|
|
| MD5 |
f152128d155edbbbe73bff60a27b3f66
|
|
| BLAKE2b-256 |
49c38749163cf07f7371a969ccc4b55f876f1387757e8037a90fd7e6903c567e
|