Commit graph

14 commits

Author SHA1 Message Date
RussellBallestrini
e95b5d8c10 python3.x merge caused issues with python2.x compat
instead of importing division from future we simply use int() to cast
floats to integers.

nosetests: on python2.7 passes
python2 test_ago.py: passes
python3 test_ago.py: passes

TODO: Does nosetests work with python3.x?

branch 'default'
changed ago.py
changed test_ago.py
2014-02-25 11:55:43 -05:00
sbraz
cd08476137 Added Python 3 compatibility. 2014-02-21 22:44:06 +01:00
RussellBallestrini
c1991cd380 Reverted back to using a counter 'count' to keep track of precision.
Using our own counter, opposed to enumerates, allows us to skip increment::

 if d[ unit ] == 0: continue # skip 0's

The continue moves us back to the top of the loop, and which bypasses count += 1.  This allows us to have a datetime/timedelta that has a 0 value for a unit, and it will not effect precision fufillment.

For example, review this test::

 ONE_YEAR_FOUR_HOURS_DELTA = timedelta( 365, 14400, 0 )

 def test_zero_day_is_skipped_display_hour():
     _result = human( ONE_YEAR_FOUR_HOURS_DELTA, precision = 2 )
     assert 'year' in _result
     # day is 0 so it is skipped, so we should show hours ...
     assert 'hour' in _result

This test will fail using enumerate or using a slice on the units[:precision] tuple.
2013-05-23 09:42:39 -04:00
RussellBallestrini
49ff995130 Removed need to keep track of counter, which reduces complexity
and chance of introducing errors, by slicing the the units tuple
by the percision.  Removed __main__ because nosetest --with-coverage
was flagging it.  It was un-nessasary.

Special thanks to Eric Rasmussen who inspired this commit.
2013-05-22 23:17:53 -04:00
RussellBallestrini
a2574a05d8 ago 0.0.5 version
* consolidated human and delta2human
* fixed docs and tests to reflect consolidation
2013-01-12 15:06:09 -05:00
RussellBallestrini
fb0ffca26e * adjusted past_format and future_format to past_tense and future_tense
* corrected all tests and documentation to reflect new keyword argument names
* changed example _tense strings to use {} instead of {0}
* cleaned up docstrings
2013-01-12 14:17:49 -05:00
RussellBallestrini
3cbd5101b3 The format keyword arguments were mismatched between human and delta2human.
The name of these arguments is still up for discussion.
2013-01-09 09:47:46 -05:00
RussellBallestrini
7333e31f43 * Added a bunch of tests
* refactored abs(delta) into delta2dict
2013-01-08 21:25:45 -05:00
RussellBallestrini
89d73aa9dd Integrated David Beitey's code (https://bitbucket.org/davidjb)
https://bitbucket.org/russellballestrini/ago/pull-request/1/add-support-for-future-dates-minor-readme/
2013-01-08 20:43:48 -05:00
RussellBallestrini
9406a387a2 moved test to its own file 2013-01-07 21:57:22 -05:00
RussellBallestrini
237a6f508a Altered human to support future dates
We should move tests into its own file
2013-01-07 21:12:29 -05:00
RussellBallestrini
51b63aa576 moved human to delta2human and created a new wrapper function
called human which works on datetime objects instead of timedelta objects.

Updated README to document new function usage.
2012-07-29 09:15:03 -04:00
RussellBallestrini
ce0c9579b6 added a README 2012-06-29 19:56:25 -04:00
RussellBallestrini
c672eb00c9 first commit, packaged on pypi, easy_install ago! 2012-06-29 19:25:55 -04:00