Commit graph

39 commits

Author SHA1 Message Date
Chad Birch
217a7fbe61 Refactor get_delta_from_subject() method
Refactors the get_delta_from_subject() method for a few benefits:

* Checks type more idiomatically (using isinstance instead of type)
* Raise a TypeError if passed a type that isn't able to be handled
* Return immediately if passed a timedelta, so the rest of the method
  doesn't need to be inside an else block
2018-10-05 21:32:42 -06:00
russellballestrini
b2f6af9d70 The result of running black .
changed ago.py
changed setup.py
changed test_ago.py
2018-05-25 17:33:10 -04:00
russellballestrini
36102bba88 fix millisecs versus microsecs
changed ago.py
changed setup.py
changed test_ago.py
2017-10-14 20:49:50 -04:00
russellballestrini
ddcd765260 changed setup.py 2017-10-14 20:15:53 -04:00
russellballestrini
93c6b1c572 changed ago.py 2017-10-14 20:13:21 -04:00
c4a62c9690 refactoring
changed ago.py
2016-09-21 16:56:23 -04:00
5c9ba685d2 version 0.0.9 support for int/float timestamps
changed README.rst
changed ago.py
changed setup.py
changed test_ago.py
2016-09-21 16:31:48 -04:00
russellballestrini
e5a4850368 release 0.0.8
user: russellballestrini
branch 'default'
changed README.rst
changed ago.py
changed setup.py
2016-07-10 14:34:28 -04:00
david
5ad4d84a97 timezone stripping 2016-07-10 18:29:49 +02:00
russellballestrini
f586eaa8cb new release, adds abbreviate parameter! 2016-02-01 23:24:38 -05:00
sbraz
770fb5f3c4 Changed tests and added print_function for Python 2.6 compatibility. 2014-02-27 14:35:30 +01:00
RussellBallestrini
8b45e6b8b3 version 0.0.6
bumping version so I can deploy a new package on pypi!

changed setup.py
2014-02-25 11:57:54 -05:00
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
76847a986a wrote a failing test case to prove that my most recent counter removal commit
caused a hidden functional bug.  Next commit should alter ago.py to make this te
st pass.

test_zero_day_is_skipped_display_hour()
2013-05-23 09:27:41 -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
1e4fe16b72 Fixed test to use types 2013-01-12 14:27:23 -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
9e841d1266 ago.py 0.0.4 release
Special thanks to David Beitey (http://davidjb.com/) for supplying code and inspiration for this update!

All changes are backward compatible.

Changelog:

 * added support for future dates
 * added optional format_past keyword argument string for custom output
 * added optional format_future keyword argument string for custom output
 * added 13 tests to help prevent regressions
 * Updated the README.rst documentation for better coverage
2013-01-08 22:36:07 -05:00
RussellBallestrini
daf089fd28 Switched order of intro and how to install in README 2013-01-08 22:23:26 -05:00
RussellBallestrini
3968b4ea23 Added some example output to README.rst 2013-01-08 22:19:20 -05:00
RussellBallestrini
e0d0c40e05 More Documentation in README 2013-01-08 22:05:26 -05:00
RussellBallestrini
7333e31f43 * Added a bunch of tests
* refactored abs(delta) into delta2dict
2013-01-08 21:25:45 -05:00
RussellBallestrini
bcb2798a3f Fix test to reflect new future logic 2013-01-08 20:48:57 -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
87afe070a3 Another test 2013-01-08 00:50:57 -05:00
RussellBallestrini
846593e20b Added 4 tests, more test coverage needed 2013-01-08 00:31:51 -05:00
RussellBallestrini
9406a387a2 moved test to its own file 2013-01-07 21:57:22 -05:00
RussellBallestrini
ec3cf8fbfb Update README.rst to document future human deltas 2013-01-07 21:37:34 -05:00
RussellBallestrini
7b58f3d73c David Beitey suggested adjusting README to README.rst
https://bitbucket.org/davidjb <- thanks!
2013-01-07 21:16:00 -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
6dc3268ff7 forgot to commit setup.py changes 2012-07-29 09:40:48 -04: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
389ee21762 added repo link to README 2012-06-29 20:38:27 -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