Commit graph

24 commits

Author SHA1 Message Date
Chad Birch
aa6d7498a2 Handle timezone in get_delta_from_subject() 2018-10-05 21:44:50 -06:00
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
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
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