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