diff --git a/README.rst b/README.rst index 65ea42e..0a75387 100644 --- a/README.rst +++ b/README.rst @@ -1,8 +1,14 @@ How to install =================== -easy_install ago +There are a number of ways to install this package:: + easy_install ago + + pip install ago + +or specify *ago* under the *setup_requires* list within your +*setuptools*-compatible project's *setup.py* file. How to use ================== @@ -18,9 +24,10 @@ You really only need to worry about *human*:: from ago import human, delta2human, delta2dict from datetime import datetime + from datetime import timedelta # pretend this was stored in database - d1 = datetime( + db_date = datetime( year = 2010, month=5, day=4, @@ -31,11 +38,19 @@ You really only need to worry about *human*:: ) # to find out how long ago, use the human function - print 'Created ' + human( d1 ) + ' ago.' + print 'Created ' + human( db_date ) + ' ago.' # optionally pass a precision - print 'Created ' + human( d1, 3 ) + ' ago.' - print 'Created ' + human( d1, 6 ) + ' ago.' + print 'Created ' + human( db_date, 3 ) + ' ago.' + print 'Created ' + human( db_date, 6 ) + ' ago.' + +We also support future dates and times:: + + present = datetime.now() + past = present - timedelta( 492, 58711, 45 ) # days, secs, ms + future = present + timedelta( 2, 12447, 963 ) # days, secs, ms + + print 'Shutdown in ' + human( future ) Now we will document how to use delta2human and delta2dict:: @@ -48,7 +63,7 @@ Now we will document how to use delta2human and delta2dict:: # display a human readable timedelta from a timedelta print 'Created ' + delta2human( delta ) + ' ago.' - # create a dictionary out of the timedelta + # create a dictionary out of the timedelta delta_dict = delta2dict( delta ) print delta_dict