added a README

This commit is contained in:
RussellBallestrini 2012-06-29 19:56:25 -04:00
parent c672eb00c9
commit ce0c9579b6
3 changed files with 79 additions and 24 deletions

59
README Normal file
View 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

28
ago.py
View file

@ -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()

View file

@ -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