arrow-py / arrow

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

Add ability to start week span on Sunday #812

Closed oakt closed 4 years ago

oakt 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

Issue #355 fixed

Changed isoweekday function in arrow.py so it takes in extra parameter startSunday, which is a bool (default false) that determines if week should start on Sunday instead of Monday. If true, it returns (1-7) for (Sunday-Saturday) instead of (Monday-Sunday).

Changed span function to also take in startSunday parameter (via kwargs). If startSunday is true, span will call isoweekday(True) instead of isoweekday(), so span('week') will return a week starting on Sunday and ending on Monday.

Close: #355

codecov-commenter commented 4 years ago

Codecov Report

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

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #812   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           10        10           
  Lines         1757      1763    +6     
  Branches       300       302    +2     
=========================================
+ Hits          1757      1763    +6     
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 74450bb...954cf42. Read the comment docs.

krisfremen commented 4 years ago

Hi @oakt, thanks for the contribution. It seems that the linting CI is failing. Can you run pre-commit run --all-files to fix the issues and push again?

oakt commented 4 years ago

Unfortunately the pre-commit command isn't working on my device (MacOS), however the code did pass "make lint" initially. Is there another command I can try? Thanks

jadchaar commented 4 years ago

Hey @oakt, you need to install pre-commit either globally or in the virtual environment: pip install pre-commit. Or you can install it with home brew!

Running make lint requires pre-commit, so you probably already have it in the virtual env. If it runs, you need to add and commit the changes files.

systemcatch commented 4 years ago

We should probably implement this as an ability to start the week on any day, not just Sunday. Let's revisit this once we have a better implementation strategy.