diff --git a/README b/README new file mode 100644 index 0000000..d4348c3 --- /dev/null +++ b/README @@ -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 + + + diff --git a/ago.py b/ago.py index 13b1054..6e1515e 100644 --- a/ago.py +++ b/ago.py @@ -26,23 +26,19 @@ def human( delta, precision = 1 ): def test(): """Test and example usage""" from datetime import datetime - - d1 = datetime( year = 2009, month=5, day=4, hour=6, minute=54, second=33, microsecond=4000 ) - d2 = datetime( year = 2011, month=10, day=6, hour=8, minute=55, second=36 ) - + d1 = datetime( + year = 2009, + month=5, + day=4, + hour=6, + minute=54, + second=33, + microsecond=4000 + ) + d2 = datetime.now() delta = d2 - d1 - + print 'This is just the ago.py test:' print delta2dict( delta ) - print 'Created ' + human( delta ) + ' ago.' - print 'Created ' + human( delta, 3 ) + ' ago.' - print 'Created ' + human( delta, 6 ) + ' ago.' - - d3 = datetime.now() - delta = d3 - d2 - - print 'Posted ' + human( delta ) + ' ago' print 'Commented ' + human( delta, 3 ) + ' ago' - print 'Edited ' + human( delta, 6 ) + ' ago' -if __name__ == "__main__": - test() +if __name__ == "__main__": test() diff --git a/setup.py b/setup.py index a98ec56..e489937 100644 --- a/setup.py +++ b/setup.py @@ -3,21 +3,21 @@ from setuptools import setup setup( - name='ago', - version='0.0.1', - description='ago: Human readable timedeltas', + name = 'ago', + version = '0.0.2', + description = 'ago: Human readable timedeltas', + keywords = 'ago human readable time deltas timedelta', + long_description = open('README').read(), author = 'Russell Ballestrini', author_email = 'russell@ballestrini.net', - keywords = 'ago human readable time deltas timedelta', url = 'https://bitbucket.org/russellballestrini/ago/src', - platforms=['All'], - license='Public Domain', + platforms = ['All'], + license = 'Public Domain', - #package_dir = {'': ''}, py_modules = ['ago'], - include_package_data=True, + include_package_data = True, ) # setup keyword args: http://peak.telecommunity.com/DevCenter/setuptools