added a README
This commit is contained in:
parent
c672eb00c9
commit
ce0c9579b6
3 changed files with 79 additions and 24 deletions
59
README
Normal file
59
README
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
How to install
|
||||
===================
|
||||
|
||||
easy_install ago
|
||||
|
||||
|
||||
How to use
|
||||
==================
|
||||
|
||||
Import ago and create a timedelta object::
|
||||
|
||||
from ago import delta2dict, human
|
||||
|
||||
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
|
||||
)
|
||||
|
||||
# this is right now
|
||||
d2 = datetime.now()
|
||||
|
||||
# subtract the two for a timedelta object
|
||||
delta = d2 - d1
|
||||
|
||||
# create a dictionary out of the timedelta
|
||||
# not needed but accessable
|
||||
delta_dict = delta2dict( delta )
|
||||
print delta_dict
|
||||
|
||||
# display a human readable timedelta
|
||||
print 'Created ' + human( delta ) + ' ago.'
|
||||
|
||||
# optionally pass a precision
|
||||
print 'Created ' + human( delta, 3 ) + ' ago.'
|
||||
print 'Created ' + human( delta, 6 ) + ' ago.'
|
||||
|
||||
|
||||
|
||||
How do I thank you?
|
||||
==========================
|
||||
|
||||
You should follow me on twitter http://twitter.com/russellbal
|
||||
|
||||
|
||||
License
|
||||
=========================
|
||||
|
||||
Public Domain
|
||||
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue