27 lines
763 B
Python
27 lines
763 B
Python
from ago import human
|
|
from ago import delta2dict
|
|
from ago import delta2human
|
|
|
|
def test_output():
|
|
"""Test and example usage"""
|
|
from datetime import datetime
|
|
from datetime import timedelta
|
|
|
|
present = datetime.now()
|
|
past = present - timedelta( 492, 58711, 45 ) # days, secs, ms
|
|
future = present + timedelta( 2, 12447, 963 ) # days, secs, ms
|
|
|
|
pdelta = present - past
|
|
fdelta = future - present
|
|
|
|
print '\nTesting past:\n'
|
|
print delta2dict( pdelta )
|
|
print 'Commented ' + delta2human( pdelta, 3 ) + ' ago'
|
|
print 'Commented ' + human( past ) + ' ago'
|
|
|
|
print '\nTesting future:\n'
|
|
print delta2dict( fdelta )
|
|
print 'Shutdown in ' + delta2human( fdelta, 3 )
|
|
print 'Shutdown in ' + human( future )
|
|
print ''
|
|
|