From 3cbd5101b3ed9f6969f0a68f9e4e44737e5b930b Mon Sep 17 00:00:00 2001 From: RussellBallestrini Date: Wed, 9 Jan 2013 09:47:46 -0500 Subject: [PATCH] The format keyword arguments were mismatched between human and delta2human. The name of these arguments is still up for discussion. --- README.rst | 16 ++++++++-------- ago.py | 4 ++-- test_ago.py | 12 ++++++------ 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/README.rst b/README.rst index d1a6b74..7b2f932 100644 --- a/README.rst +++ b/README.rst @@ -40,7 +40,7 @@ You really only need to worry about *human*. Here are all the available arguments and defaults:: - human(d, precision=2, format_past='{0} ago', format_future='in {0}'): + human(d, precision=2, past_format='{0} ago', future_format='in {0}'): d datetime object to make into human readable, required @@ -48,10 +48,10 @@ d precision control how verbose the output should look, optional -format_past +past_format format string used when d is a past datetime, optional -format_future +future_format format string used when d is a future datetime, optional @@ -99,16 +99,16 @@ Now we will document how to use delta2human and delta2dict:: # create a dictionary out of the timedelta print delta2dict( delta ) -Example format_past and format_future keyword arguments:: +Example past_format and future_format keyword arguments:: output1 = human( PAST, - format_past = 'titanic sunk {0} ago', - format_future = 'titanic will sink in {0} from now' + past_format = 'titanic sunk {0} ago', + future_format = 'titanic will sink in {0} from now' ) output2 = human( FUTURE, - format_past = 'titanic sunk {0} ago', - format_future = 'titanic will sink in {0} from now' + past_format = 'titanic sunk {0} ago', + future_format = 'titanic will sink in {0} from now' ) print output1 diff --git a/ago.py b/ago.py index d7e88c4..0ef8d2e 100644 --- a/ago.py +++ b/ago.py @@ -30,10 +30,10 @@ def delta2human(delta, precision=2, past_format='{0} ago', future_format='in {0} human_delta = ', '.join( hlist ) return the_format.format(human_delta) -def human(d, precision=2, format_past='{0} ago', format_future='in {0}'): +def human(d, precision=2, past_format='{0} ago', future_format='in {0}'): """Pass datetime we will return human delta string""" delta = datetime.now() - d - return delta2human( delta, precision, format_past, format_future ) + return delta2human( delta, precision, past_format, future_format ) if __name__ == "__main__": from test_ago import test_output diff --git a/test_ago.py b/test_ago.py index 7309c3c..b673b9b 100644 --- a/test_ago.py +++ b/test_ago.py @@ -43,15 +43,15 @@ def test_two_day_plural(): def test_past_format(): output = human( PAST, - format_past = 'titanic sunk {0} ago', - format_future = 'titanic will sink in {0} from now' + past_format = 'titanic sunk {0} ago', + future_format = 'titanic will sink in {0} from now' ) assert 'titanic sunk' in output def test_future_format(): output = human( FUTURE, - format_past = 'titanic sunk {0} ago', - format_future = 'titanic will sink in {0} from now' + past_format = 'titanic sunk {0} ago', + future_format = 'titanic will sink in {0} from now' ) assert 'titanic will sink in' in output @@ -69,11 +69,11 @@ def test_output(): print '\nTesting past:\n' print delta2dict( PAST_DELTA ) print 'Commented ' + delta2human( PAST_DELTA, 3 ) - print human( PAST, format_past = "Commented {0} ago" ) + print human( PAST, past_format = "Commented {0} ago" ) print '\nTesting future:\n' print delta2dict( FUTURE_DELTA ) print 'Shutdown ' + delta2human( FUTURE_DELTA, 3 ) - print human( FUTURE, format_future = 'Shutdown in {0} from now' ) + print human( FUTURE, future_format = 'Shutdown in {0} from now' ) print ''