arrow-py / arrow

🏹 Better dates & times for Python
https://arrow.readthedocs.io
Apache License 2.0
8.71k stars 673 forks source link

kwarg 'exact' in span, span_range and interval #817

Closed jadchaar closed 4 years ago

jadchaar commented 4 years ago

Pull Request Checklist

Thank you for taking the time to improve Arrow! Before submitting your pull request, please check all appropriate boxes:

If you have any questions about your code changes or any of the points above, please submit your questions along with the pull request and we will try our best to help!

Description of Changes

Updated https://github.com/crsmithdev/arrow/pull/731 to latest master changes.

Closes: https://github.com/crsmithdev/arrow/issues/498

codecov-commenter commented 4 years ago

Codecov Report

Merging #817 into master will not change coverage. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #817   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            9         9           
  Lines         1771      1785   +14     
  Branches       304       308    +4     
=========================================
+ Hits          1771      1785   +14     
Impacted Files Coverage Δ
arrow/arrow.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update b7a7403...8154e18. Read the comment docs.

systemcatch commented 4 years ago

@jadchaar this was the bug we found, the last tuple ends up being wrong.

from datetime import datetime
import arrow

start = datetime(2013, 5, 5, 12, 30)
end = datetime(2013, 5, 5, 12, 40)

for r in arrow.Arrow.span_range('minute', start, end, exact=True):
    print(r)
(<Arrow [2013-05-05T12:30:00+00:00]>, <Arrow [2013-05-05T12:30:59.999999+00:00]>)
(<Arrow [2013-05-05T12:31:00+00:00]>, <Arrow [2013-05-05T12:31:59.999999+00:00]>)
(<Arrow [2013-05-05T12:32:00+00:00]>, <Arrow [2013-05-05T12:32:59.999999+00:00]>)
(<Arrow [2013-05-05T12:33:00+00:00]>, <Arrow [2013-05-05T12:33:59.999999+00:00]>)
(<Arrow [2013-05-05T12:34:00+00:00]>, <Arrow [2013-05-05T12:34:59.999999+00:00]>)
(<Arrow [2013-05-05T12:35:00+00:00]>, <Arrow [2013-05-05T12:35:59.999999+00:00]>)
(<Arrow [2013-05-05T12:36:00+00:00]>, <Arrow [2013-05-05T12:36:59.999999+00:00]>)
(<Arrow [2013-05-05T12:37:00+00:00]>, <Arrow [2013-05-05T12:37:59.999999+00:00]>)
(<Arrow [2013-05-05T12:38:00+00:00]>, <Arrow [2013-05-05T12:38:59.999999+00:00]>)
(<Arrow [2013-05-05T12:39:00+00:00]>, <Arrow [2013-05-05T12:39:59.999999+00:00]>)
(<Arrow [2013-05-05T12:40:00+00:00]>, <Arrow [2013-05-05T12:39:59.999999+00:00]>)
jadchaar commented 4 years ago

Closing this for now until we get a chance to take a closer look at the issue.