Almost all of this was borrowed from the py-pretty library, tested then refactored.
py-pretty Functionaility
>>> from datetime import datetime, timedelta >>> from pretty_times import pretty >>> now = datetime.now() >>> pretty.date(now) 'now' >>> pretty.date(now - timedelta(seconds=30)) '30 seconds ago' >>> pretty.date(now + timedelta(seconds=31)) 'in 30 seconds' >>> pretty.date(now - timedelta(minutes=1)) 'a minute ago' >>> pretty.date(now + timedelta(minutes=1, seconds=1)) 'in a minute' >>> pretty.date(now - timedelta(hours=1)) 'an hour ago' >>> pretty.date(now + timedelta(hours=1, seconds=1)) 'in an hour' >>> pretty.date(now - timedelta(days=1)) 'yesterday' >>> pretty.date(now + timedelta(days=1, seconds=1)) 'tomorrow' >>> pretty.date(now - timedelta(days=2)) '2 days ago' >>> pretty.date(now + timedelta(days=2, seconds=1)) 'in 2 days' >>> pretty.date(now - timedelta(days=9)) 'last week' >>> pretty.date(now + timedelta(days=9, seconds=1)) 'next week' >>> pretty.date(now - timedelta(days=16)) '2 weeks ago' >>> pretty.date(now + timedelta(days=16, seconds=1)) 'in 2 weeks' >>> pretty.date(now - timedelta(days=32)) 'last month' >>> pretty.date(now + timedelta(days=32, seconds=1)) 'next month' >>> pretty.date(now - timedelta(days=64)) '2 months ago' >>> pretty.date(now + timedelta(days=64, seconds=1)) 'in 2 months' >>> pretty.date(now - timedelta(days=367)) 'last year' >>> pretty.date(now + timedelta(days=367, seconds=1)) 'next year' >>> pretty.date(now - timedelta(days=735)) '2 years ago' >>> pretty.date(now + timedelta(days=735, seconds=1)) 'in 2 years'
Django Integration
{% load prettytimes_tags %}
{{ my_datetime|relative_time }}
Metadata
Release files for django-pretty-times 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-pretty-times-0.2.0.tar.gz | 6.0 kB | Without provenance | Details for django-pretty-times-0.2.0.tar.gz |
Release files / django-pretty-times-0.2.0.tar.gz
| Download URL | django-pretty-times-0.2.0.tar.gz |
|---|---|
| Size | 6.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e4e96488859a31d70d99101696ba5cb7a81893adb826549abbe5a99410f153ed
|
|
BLAKE2b-256 checksum How to use checksums |
10bcffa5c18669af312a39d3a562977acc5b58ae9b187ff0cb2d05652f7204d6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for django-pretty-times 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.