ago: Human readable timedeltas
Project description
How to install
easy_install ago
How to use
The ago module comes with three functions:
human
delta2human
delta2dict
You really only need to worry about human:
from ago import human, delta2human, delta2dict from datetime import datetime # pretend this was stored in database d1 = datetime( year = 2010, month=5, day=4, hour=6, minute=54, second=33, microsecond=4000 ) # to find out how long ago, use the human function print 'Created ' + human( d1 ) + ' ago.' # optionally pass a precision print 'Created ' + human( d1, 3 ) + ' ago.' print 'Created ' + human( d1, 6 ) + ' ago.'
Now we will document how to use delta2human and delta2dict:
# pretend we already have a timedelta object # subtract two datetime objects for a timedelta object d2 = datetime.now() delta = d2 - d1 # display a human readable timedelta from a timedelta print 'Created ' + delta2human( delta ) + ' ago.' # create a dictionary out of the timedelta delta_dict = delta2dict( delta ) print delta_dict
How do I thank you?
You should follow me on twitter http://twitter.com/russellbal
License
Public Domain
Public Revision Control
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
ago-0.0.3.tar.gz
(2.2 kB
view details)
Built Distribution
ago-0.0.3-py2.7.egg
(3.2 kB
view details)
File details
Details for the file ago-0.0.3.tar.gz
.
File metadata
- Download URL: ago-0.0.3.tar.gz
- Upload date:
- Size: 2.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ea3e570180aeab2433804decd4c9e0a501d553a2e34a20f07eb91e3e145f3736 |
|
MD5 | 72115c3ea32c8717c9f7d532e61a7284 |
|
BLAKE2b-256 | dcc7ed287035f9b9c45fdb26850217ad63ccffbbdcb89ee2c44489ae11c30fde |
File details
Details for the file ago-0.0.3-py2.7.egg
.
File metadata
- Download URL: ago-0.0.3-py2.7.egg
- Upload date:
- Size: 3.2 kB
- Tags: Egg
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | af10daed5701016ecd7d9f1abdc62ee3b78a7ed27f2795305384c3b769679be8 |
|
MD5 | 15d7284d30a93877ebed1a978b6d587f |
|
BLAKE2b-256 | 779884de8de089937b0df6342ec52333eef106fb3bf7cc00fb4b2017769050c7 |