David Beitey suggested adjusting README to README.rst
https://bitbucket.org/davidjb <- thanks!
This commit is contained in:
parent
237a6f508a
commit
7b58f3d73c
2 changed files with 1 additions and 1 deletions
72
README.rst
Normal file
72
README.rst
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
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
|
||||
==============================
|
||||
|
||||
https://bitbucket.org/russellballestrini/ago
|
||||
Loading…
Add table
Add a link
Reference in a new issue